Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use importValue and join in Cloudformation

I have a stack which depends on a value which is exported in a different stack (value is supertest)

I try to use it as below

OriginAccessIdentity: !Join [ "", [ "origin-access-identity/cloudfront/", !ImportValue: !Sub "supertest-${Environment}" ] ]

But I got a syntax error while this works (hardcoding the supertest value)

OriginAccessIdentity: !Join [ "", [ "origin-access-identity/cloudfront/", "lol-dev" ] ]
like image 516
mealesbia Avatar asked Nov 08 '18 08:11

mealesbia


Video Answer


1 Answers

I believe that syntax is not valid.

Try this:

OriginAccessIdentity:
  Fn::Join:
    - ""
    - - "origin-access-identity/cloudfront/"
      - Fn::ImportValue: !Sub "supertest-${Environment}"

Here is another example where i use it similarly: https://github.com/faermanj/Sitting-Ducks/blob/master/cfn-beanstalk-env.yml

like image 82
Julio Faerman Avatar answered Oct 22 '22 16:10

Julio Faerman