Skip to content

Cloudformation: Stack에서 Output value export하기 & export 된 value를 다른 stack에서 import해 오기

TaeSeong Park edited this page Jun 30, 2020 · 6 revisions

Output Value Export하기

  • 참고자료

  • frontend/kendra-button-front/amplify/backend/auth/kendrabuttonhosting28eb127d/kendrabuttonhosting28eb127d-cloudformation-template.yml

    Outputs :
      ...
      UserPoolId:
        Value: !Ref 'UserPool'
        Description:  Id for the user pool
        Export:
          Name: "kendraUserpoolId"
  • amplify push

  • AWS console의 Cloudformation의 Stack을 눌러서 Output탭을 눌러 직접 확인 스크린샷 2020-07-01 오전 12 32 39

Export된 Value Import 해 오기

  • 참고자료

  • frontend/kendra-button-front/amplify/backend/function/kendrabuttonhosting28eb127dPreSignup/kendrabuttonhosting28eb127dPreSignup-cloudformation-template.json

      "lambdaexecutionpolicy": {
        "DependsOn": [
          "LambdaExecutionRole"
        ],
        "Type": "AWS::IAM::Policy",
        "Properties": {
          "PolicyName": "lambda-execution-policy",
          "Roles": [
            {
              "Ref": "LambdaExecutionRole"
            }
          ],
          "PolicyDocument": {
            "Version": "2012-10-17",
            "Statement": [
              ...
              {
                "Effect": "Allow",
                "Action": [
                  "cognito-idp:ListUsers",
                  "cognito-idp:AdminLinkProviderForUser"
                ],
                "Resource": {
                  "Fn::Sub": [
                    "arn:aws:cognito-idp:${region}:${account}:userpool/${userpool}",
                    {
                      "region": {
                        "Ref": "AWS::Region"
                      },
                      "account": {
                        "Ref": "AWS::AccountId"
                      },
                      "userpool": {
                        "Fn::ImportValue": "kendraUserpoolId"
                      }
                    }
                  ]
                }
              }
            ]
          }
        }
      }

주의

import하려는 value는 이미 배포된 CloudFormation에서 가져와 사용하는 것이기 때문에, Output Export 설정을 함과 동시에 Fn::ImportValue를 사용한다면 에러가 나온다.