Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can use environment variables with the sub intrinsic function?

I am using the sub function to define a resource within an aws IAM service.

Resource:
  - !Sub 'arn:aws:s3:::example-${TEST1}-${AWS::REGION}-test'

${TEST1}: it is an environment variable that I have in my java project.

${AWS::REGION}: pseudo parameter

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I want to know if !sub is able to read the environment variable and if it can’t, is there any way I can do it even if it’s not with this function

>Solution :

No, you cannot reference environment variables within cloudformation.

You’ll have to wrap the cloudformation deployment with a script that parses the environment variables and feeds them in as parameters, which can then be referenced in the template.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading