How to use importValue and join in Cloudformation











up vote
0
down vote

favorite












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" ] ]









share|improve this question


























    up vote
    0
    down vote

    favorite












    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" ] ]









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      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" ] ]









      share|improve this question













      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" ] ]






      amazon-web-services amazon-cloudformation






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 8 at 8:21









      mealesbia

      386




      386
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          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






          share|improve this answer





















          • This works, now I also need to put this inside a cloudformation if: !If [check, if true then the Fn::Join: - "", .. (the parth above); , if false then just "ok"]. Can you help me with that?
            – mealesbia
            Nov 8 at 14:01










          • Great, try using each statement/argument in separate line and always validate the YAML. The cloudformation lint is quite useful: github.com/awslabs/cfn-python-lint
            – faermanj
            2 days ago











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203799%2fhow-to-use-importvalue-and-join-in-cloudformation%23new-answer', 'question_page');
          }
          );

          Post as a guest
































          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          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






          share|improve this answer





















          • This works, now I also need to put this inside a cloudformation if: !If [check, if true then the Fn::Join: - "", .. (the parth above); , if false then just "ok"]. Can you help me with that?
            – mealesbia
            Nov 8 at 14:01










          • Great, try using each statement/argument in separate line and always validate the YAML. The cloudformation lint is quite useful: github.com/awslabs/cfn-python-lint
            – faermanj
            2 days ago















          up vote
          1
          down vote



          accepted










          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






          share|improve this answer





















          • This works, now I also need to put this inside a cloudformation if: !If [check, if true then the Fn::Join: - "", .. (the parth above); , if false then just "ok"]. Can you help me with that?
            – mealesbia
            Nov 8 at 14:01










          • Great, try using each statement/argument in separate line and always validate the YAML. The cloudformation lint is quite useful: github.com/awslabs/cfn-python-lint
            – faermanj
            2 days ago













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          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






          share|improve this answer












          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







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 8 at 8:45









          faermanj

          7,87054565




          7,87054565












          • This works, now I also need to put this inside a cloudformation if: !If [check, if true then the Fn::Join: - "", .. (the parth above); , if false then just "ok"]. Can you help me with that?
            – mealesbia
            Nov 8 at 14:01










          • Great, try using each statement/argument in separate line and always validate the YAML. The cloudformation lint is quite useful: github.com/awslabs/cfn-python-lint
            – faermanj
            2 days ago


















          • This works, now I also need to put this inside a cloudformation if: !If [check, if true then the Fn::Join: - "", .. (the parth above); , if false then just "ok"]. Can you help me with that?
            – mealesbia
            Nov 8 at 14:01










          • Great, try using each statement/argument in separate line and always validate the YAML. The cloudformation lint is quite useful: github.com/awslabs/cfn-python-lint
            – faermanj
            2 days ago
















          This works, now I also need to put this inside a cloudformation if: !If [check, if true then the Fn::Join: - "", .. (the parth above); , if false then just "ok"]. Can you help me with that?
          – mealesbia
          Nov 8 at 14:01




          This works, now I also need to put this inside a cloudformation if: !If [check, if true then the Fn::Join: - "", .. (the parth above); , if false then just "ok"]. Can you help me with that?
          – mealesbia
          Nov 8 at 14:01












          Great, try using each statement/argument in separate line and always validate the YAML. The cloudformation lint is quite useful: github.com/awslabs/cfn-python-lint
          – faermanj
          2 days ago




          Great, try using each statement/argument in separate line and always validate the YAML. The cloudformation lint is quite useful: github.com/awslabs/cfn-python-lint
          – faermanj
          2 days ago


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203799%2fhow-to-use-importvalue-and-join-in-cloudformation%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          Popular posts from this blog

          Schultheiß

          Verwaltungsgliederung Dänemarks

          Liste der Kulturdenkmale in Wilsdruff