Giter VIP home page Giter VIP logo

magicmodules-terraformtools's Introduction

Hi there ๐Ÿ‘‹

Hi, I'm a Python Software Engineer with a decade of IT Experience IT. I like automation, data analytics, data engineering & software development.

magicmodules-terraformtools's People

Contributors

betsy-lichtenberg avatar msampathkumar avatar

Watchers

 avatar  avatar  avatar  avatar

magicmodules-terraformtools's Issues

Script should handle case when `name` argument references random_pet resource

random_pet is a commonly used Terraform resource for randomizing resource names to prevent duplicates.

This sample uses random_pet to help ensure that the new bucket resource has a unique name.

Similarly, here is another samplethat uses random_pet for many of the resource names.

When I run tftools, I get the following parsing error:


	Error: Failed to find name for the following line
		--->[name                        = "bucket-${random_pet.suffix.id}"]<---
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tftools-1.0-py3.7.egg/convert2erb.py", line 125, in get_resource_name
    name = re.findall(resource_name_regex_pattern, text)[0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/tftools", line 11, in <module>
    load_entry_point('tftools==1.0', 'console_scripts', 'tftools')()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tftools-1.0-py3.7.egg/tftools.py", line 35, in main
    convert2erb.parse_user_args(sys.argv)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tftools-1.0-py3.7.egg/convert2erb.py", line 341, in parse_user_args
    convert_to_erb(filename)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tftools-1.0-py3.7.egg/convert2erb.py", line 306, in convert_to_erb
    tf_resource_parser(filename)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tftools-1.0-py3.7.egg/convert2erb.py", line 114, in wrap_func
    result = func(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tftools-1.0-py3.7.egg/convert2erb.py", line 193, in tf_resource_parser
    rname = get_resource_name(resource_name_lines[-1])
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tftools-1.0-py3.7.egg/convert2erb.py", line 133, in get_resource_name
    raise Exception("Parsing Error!")
Exception: Parsing Error!

convert2erb.py adds primary resource ID to wrong resource

Steps to reproduce:

  1. Copy the content in https://paste.googleplex.com/5739116936298496 and create a new .tf file.
  2. Run convert2erb.py against the .tf file.
  3. When prompted for the primary resource, choose 17, which corresponds to line 267 in https://paste.googleplex.com/5739116936298496.
  4. In the output .erb file, notice that the script doesn't change line 267.
  5. Notice that the script changes line 228 instead:
    • Adds the primary resource ID to the wrong resource.
    • Changes "google_compute_instance" to "google_compute_region_url_map"

tf.erb filename must have underscores, not hyphens

Hi Sampath,

Can we force the tf.erb output filename to have underscores instead of hyphens?

Please see that all filenames have underscores here:
https://github.com/GoogleCloudPlatform/magic-modules/tree/master/mmv1/templates/terraform/examples

Also note that @rileykarson said:

Noticed this line's probably gotta use underscores instead of hyphens. It causes the generated test to create invalid Go code.

In mmv1/products/vpcaccess/terraform.yaml:

> @@ -31,6 +31,16 @@ overrides: !ruby/object:Overrides::ResourceOverrides

         min_version: beta

         vars:

           name: "vpc-con"

+      - !ruby/object:Provider::Terraform::Examples

+        name: "cloudrun-vpc-access-connector"

โฌ‡๏ธ Suggested change
-        name: "cloudrun-vpc-access-connector"

+        name: "cloudrun_vpc_access_connector"

Thanks,
Betsy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.