Cloudformation Substitution Example

, , Leave a comment

AWSTemplateFormatVersion: 2010-09-09
Description: Create DynamoDB table for Monit Application
Parameters:
  Environment:
    Default: dev
    Description: Leveraged for environment tagging.
    Type: String
    AllowedValues:
      - dev
      - tst
      - qa
      - stg
      - prd
Resources:
  MaintPolicy:
    Type: 'AWS::IAM::Policy'
    Description: Allow maintenance from onprem Jenkins instance
    Properties:
      Groups:
        - "AP4JenkinsAccess"
      PolicyName: !Sub 'monit-${Environment}-access'
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Action:
              - 'dynamodb:*'
            Resource:
              - 'Fn::Sub': >-
                 arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/monit-${Environment}/
              - 'Fn::Sub': >-
                 arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/monit-${Environment}/*
Outputs:
  myStacksRegion:
    Value: !Ref 'AWS::Region'
  myAccountId:
    Value: !Ref 'AWS::AccountId'
 

Leave a Reply