perfectsense / gyro

Gyro is a command-line tool for creating, updating, and maintaining cloud infrastructure. Gyro makes infrastructure-as-code possible.
https://gyro.dev
Apache License 2.0
134 stars 7 forks source link

`@uses-credentials` Directive does not resolve variables #341

Closed tloisel1 closed 3 years ago

tloisel1 commented 3 years ago

Describe the bug Gyro errors on state resolve when using a variable as the value to the @uses-credentials directive.

To Reproduce Create a simple VPC using a variable with the @uses-credentials directive:

region: 'us-east-1'

# VPC
aws::vpc "$(region)-vpc"
    cidr-block: "10.0.0.0/16"
    @uses-credentials: $region

Gyro up:

gyro up test.gyro
⟳ Refreshed resources: 99

Looking for changes...

+ Create aws::vpc us-east-1-vpc

Are you sure you want to change resources? (y/N) y

+ Creating aws::vpc us-east-1-vpc OK

Gyro up again:

gyro up test.gyro

Error: Can't create aws::vpc us-east-1-vpc resource!

Caused by: Error: Can't resolve region!

In test.gyro on line 5 from column 24 to 34:
5:     @uses-credentials: $('region')
6:     'cidr-block': '10.0.0.0/16'

Expected behavior Gyro should be able to resolve the variable, or save the value of the variable in the state.