cloudtools / stacker

An AWS CloudFormation Stack orchestrator/manager.
http://stacker.readthedocs.io/en/stable/
BSD 2-Clause "Simplified" License
709 stars 167 forks source link

File Lookup Not Working as Expected #635

Closed Spareo closed 6 years ago

Spareo commented 6 years ago

I have followed the documentation here https://stacker.readthedocs.io/en/latest/lookups.html#file-lookup to add file lookup to my config.yaml for sending a UserData script to my stack.

In the config.yml file I have the following under the variables section UserData: ${file parameterized-b64:file://configure.ps1}

Inside the configure.ps1 script I am referencing several other variables that I pass into the stack as well using this notation: {{VARIABLE_NAME}}

However, when I attempt to deploy the stack I get an error:

service: failed (An error occurred (ValidationError) when calling the CreateStack operation: Template format error: Unresolved resource dependencies [Project, StatsDEnvNameValue, ServiceName, PackagesBucketKey, Environment, PackagesBucket, ElastiCacheEndPointUrl, ConfigEnvironmentLabel] in the Resources block of the template)

The resource dependencies are the variables I am attempting to resolve. I can't figure out what Im doing wrong. Any help would be appreciated.

Spareo commented 6 years ago

nevermind, I figured it out right after posting this. I need to reference the variables with ${VARIABLE_NAME} instead of {{VARIABLE_NAME}} like the documentation shows.

phobologic commented 6 years ago

Ahh, the reason is that {{VARIABLE_NAME}} refers to parameters - it basically replaces that with ${Ref VARIABLE_NAME} which means you cna use it for things like the Region, etc, from the AWS Cloudformation meta parameters.

If you want to use actual stacker blueprint variables, you have the right of it - ${VARIABLE}. I'll check out the docs and see if we can make it more clear in the future.

Spareo commented 6 years ago

Yeah it’s a little sparse on examples for that stuff but I got it working. Thanks!

Spareo commented 6 years ago

@phobologic Is there a way to verify that the replacement is working?

I am getting an error that a variable I am trying to replace parameterized data into is just being read as an empty string. I verified that I have a variable defined for this property and im passing it in from the config file.

When I look at the CF template that gets generated it still shows the variables as ${VARIABLE} instead of the actual value, I wasn't sure if this was correct either.

Spareo commented 6 years ago

Yeah so I looked at the userdata script that gets generated on the instance and it still shows the variables as ${VARIABLE} as well. However, the parameterized ones that use the {{}} syntax like {{AWS::REGION}} were replaced with the correct values.

Spareo commented 6 years ago

Got on slack channel and figured out my issue. I'm good again.