Home > database >  How to reference SSM parameter in another template
How to reference SSM parameter in another template

Time:10-07

If defining a SSM parameter in cloud formation one template like this

  KinesisStreamARNParameter:
    Type: AWS::SSM::Parameter
    Properties:
      Name: !Sub "/${Environment}/Services/${Domain}/kinesis_stream_arn"
      Type: String
      Value: !GetAtt KinesisStream.Arn

How would I use in a different template file that defines a role? How would I refer to it under resources for the policy?

KinesisFirehoseRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              Service: firehose.amazonaws.com
            Action: sts:AssumeRole
      Path: /
      Policies:
        - PolicyName: KinesisFirehosePolicy
          PolicyDocument:
            Version: 2012-10-17
            Statement:
              - Effect: Allow
                Action:
                  - kinesis:*
                  - s3:*
                  - s3-object-lambda:*
                Resource:
                  - !Sub "${Bucket.Arn}/*"

CodePudding user response:

Generally there are two choices:

  1. Export the arn of your KinesisStreamARNParameter in the outputs. Then use ImportValue to reference it your second template.

  2. Pass the arn as an input parameter to your second template. This will require you to manually provide the value when you deploy the second template, or create some automation wrapper that will populate that value for you before deployment.

  • Related