templates/rdsmysql/template.yaml [959:1243]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  AWSSBInjectedLambdaZipsBucket:
    Type: AWS::S3::Bucket
    Properties:
      Tags: []
  AWSSBInjectedCopyZips:
    Type: AWS::CloudFormation::CustomResource
    Properties:
      ServiceToken: !GetAtt AWSSBInjectedCopyZipsLambda.Arn
      DestBucket: !Ref AWSSBInjectedLambdaZipsBucket
      SourceBucket: awsservicebrokeralpha
      Prefix: functions/
      Objects:
      - get_cidrs/lambda_function.zip
      - get_azs/lambda_function.zip
      - generate_password/lambda_function.zip
      - generate_dbname/lambda_function.zip
  AWSSBInjectedCopyZipsRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
        - Effect: Allow
          Principal:
            Service: lambda.amazonaws.com
          Action: sts:AssumeRole
      ManagedPolicyArns:
      - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
      Path: /
      Policies:
      - PolicyName: lambda-copier
        PolicyDocument:
          Version: 2012-10-17
          Statement:
          - Effect: Allow
            Action:
            - s3:GetObject
            Resource:
            - arn:aws:s3:::awsservicebrokeralpha/*
          - Effect: Allow
            Action:
            - s3:PutObject
            - s3:DeleteObject
            Resource:
            - !Sub arn:aws:s3:::${AWSSBInjectedLambdaZipsBucket}/*
  AWSSBInjectedCopyZipsLambda:
    Type: AWS::Lambda::Function
    Properties:
      Description: Copies objects from a source S3 bucket to a destination
      Handler: index.handler
      Runtime: python3.9
      Role: !GetAtt AWSSBInjectedCopyZipsRole.Arn
      Timeout: 240
      Code:
        ZipFile: |
          import json
          import logging
          import threading
          import boto3
          import cfnresponse


          def copy_objects(source_bucket, dest_bucket, prefix, objects):
              s3 = boto3.client('s3')
              for o in objects:
                  key = prefix + o
                  copy_source = {
                      'Bucket': source_bucket,
                      'Key': key
                  }
                  print('copy_source: %s' % copy_source)
                  print('dest_bucket = %s' % dest_bucket)
                  print('key = %s' % key)
                  s3.copy_object(CopySource=copy_source, Bucket=dest_bucket, Key=key)


          def delete_objects(bucket, prefix, objects):
              s3 = boto3.client('s3')
              objects = {'Objects': [{'Key': prefix + o} for o in objects]}
              s3.delete_objects(Bucket=bucket, Delete=objects)


          def timeout(event, context):
              logging.error('Execution is about to time out, sending failure response to CloudFormation')
              cfnresponse.send(event, context, cfnresponse.FAILED, {}, None)


          def handler(event, context):
              timer = threading.Timer((context.get_remaining_time_in_millis() / 1000.00) - 0.5, timeout, args=[event, context])
              timer.start()
              print('Received event: %s' % json.dumps(event))
              status = cfnresponse.SUCCESS
              try:
                  source_bucket = event['ResourceProperties']['SourceBucket']
                  dest_bucket = event['ResourceProperties']['DestBucket']
                  prefix = event['ResourceProperties']['Prefix']
                  objects = event['ResourceProperties']['Objects']
                  if event['RequestType'] == 'Delete':
                      delete_objects(dest_bucket, prefix, objects)
                  else:
                      copy_objects(source_bucket, dest_bucket, prefix, objects)
              except Exception as e:
                  logging.error('Exception: %s' % e, exc_info=True)
                  status = cfnresponse.FAILED
              finally:
                  timer.cancel()
                  cfnresponse.send(event, context, status, {}, None)
  AWSSBInjectedGetCidrsRole:
    Condition: AutoCidrs
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Principal:
            Service:
            - lambda.amazonaws.com
          Action:
          - sts:AssumeRole
      Path: /
      Policies:
      - PolicyName: cfn_utility_get_cidrs
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Effect: Allow
            Action:
            - ec2:DescribeVpcs
            - ec2:DescribeSubnets
            - ec2:DescribeAvailabilityZones
            - logs:CreateLogGroup
            - logs:CreateLogStream
            - logs:PutLogEvents
            Resource: '*'
  AWSSBInjectedGetCidrsLambda:
    DependsOn: AWSSBInjectedCopyZips
    Condition: AutoCidrs
    Type: AWS::Lambda::Function
    Properties:
      Handler: lambda_function.handler
      Role:
        Fn::GetAtt:
        - AWSSBInjectedGetCidrsRole
        - Arn
      Code:
        S3Bucket: !Ref AWSSBInjectedLambdaZipsBucket
        S3Key: functions/get_cidrs/lambda_function.zip
      Runtime: python3.9
      Timeout: '60'
  AWSSBInjectedGetCidrs:
    Condition: AutoCidrs
    Type: AWS::CloudFormation::CustomResource
    Properties:
      ServiceToken: !GetAtt AWSSBInjectedGetCidrsLambda.Arn
      Qty: !Ref NumberOfAvailabilityZones
      VpcId: !Ref VpcId
      CidrSize: !Ref CidrSize
  AWSSBInjectedGetAzsRole:
    Condition: AutoAzs
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Principal:
            Service:
            - lambda.amazonaws.com
          Action:
          - sts:AssumeRole
      Path: /
      Policies:
      - PolicyName: cfn_utility_get_cidrs
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Effect: Allow
            Action:
            - ec2:DescribeAvailabilityZones
            - logs:CreateLogGroup
            - logs:CreateLogStream
            - logs:PutLogEvents
            Resource: '*'
  AWSSBInjectedGetAzsLambda:
    DependsOn: AWSSBInjectedCopyZips
    Condition: AutoAzs
    Type: AWS::Lambda::Function
    Properties:
      Handler: lambda_function.handler
      Role:
        Fn::GetAtt:
        - AWSSBInjectedGetAzsRole
        - Arn
      Code:
        S3Bucket: !Ref AWSSBInjectedLambdaZipsBucket
        S3Key: functions/get_azs/lambda_function.zip
      Runtime: python3.9
      Timeout: '60'
  AWSSBInjectedGetAzs:
    Condition: AutoAzs
    Type: AWS::CloudFormation::CustomResource
    Properties:
      ServiceToken: !GetAtt AWSSBInjectedGetAzsLambda.Arn
      Qty: !Ref NumberOfAvailabilityZones
  AWSSBInjectedGeneratePasswordRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Principal:
            Service:
            - lambda.amazonaws.com
          Action:
          - sts:AssumeRole
      Path: /
      Policies:
      - PolicyName: cfn_utility_get_cidrs
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Effect: Allow
            Action:
            - logs:CreateLogGroup
            - logs:CreateLogStream
            - logs:PutLogEvents
            Resource: '*'
  AWSSBInjectedGeneratePasswordLambda:
    DependsOn: AWSSBInjectedCopyZips
    Type: AWS::Lambda::Function
    Properties:
      Handler: lambda_function.handler
      Role:
        Fn::GetAtt:
        - AWSSBInjectedGeneratePasswordRole
        - Arn
      Code:
        S3Bucket: !Ref AWSSBInjectedLambdaZipsBucket
        S3Key: functions/generate_password/lambda_function.zip
      Runtime: python3.6
      Timeout: '60'
  AWSSBInjectedGeneratePassword:
    Type: AWS::CloudFormation::CustomResource
    Properties:
      ServiceToken: !GetAtt AWSSBInjectedGeneratePasswordLambda.Arn
      Length: 32
  AWSSBInjectedGenerateDBNameRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Principal:
            Service:
            - lambda.amazonaws.com
          Action:
          - sts:AssumeRole
      Path: /
      Policies:
      - PolicyName: cfn_utility_get_cidrs
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Effect: Allow
            Action:
            - logs:CreateLogGroup
            - logs:CreateLogStream
            - logs:PutLogEvents
            Resource: '*'
  AWSSBInjectedGenerateDBNameLambda:
    DependsOn: AWSSBInjectedCopyZips
    Type: AWS::Lambda::Function
    Properties:
      Handler: lambda_function.handler
      Role:
        Fn::GetAtt:
        - AWSSBInjectedGenerateDBNameRole
        - Arn
      Code:
        S3Bucket: !Ref AWSSBInjectedLambdaZipsBucket
        S3Key: functions/generate_dbname/lambda_function.zip
      Runtime: python3.6
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



templates/redshift/template.yaml [597:881]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  AWSSBInjectedLambdaZipsBucket:
    Type: AWS::S3::Bucket
    Properties:
      Tags: []
  AWSSBInjectedCopyZips:
    Type: AWS::CloudFormation::CustomResource
    Properties:
      ServiceToken: !GetAtt AWSSBInjectedCopyZipsLambda.Arn
      DestBucket: !Ref AWSSBInjectedLambdaZipsBucket
      SourceBucket: awsservicebrokeralpha
      Prefix: functions/
      Objects:
      - get_cidrs/lambda_function.zip
      - get_azs/lambda_function.zip
      - generate_password/lambda_function.zip
      - generate_dbname/lambda_function.zip
  AWSSBInjectedCopyZipsRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
        - Effect: Allow
          Principal:
            Service: lambda.amazonaws.com
          Action: sts:AssumeRole
      ManagedPolicyArns:
      - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
      Path: /
      Policies:
      - PolicyName: lambda-copier
        PolicyDocument:
          Version: 2012-10-17
          Statement:
          - Effect: Allow
            Action:
            - s3:GetObject
            Resource:
            - arn:aws:s3:::awsservicebrokeralpha/*
          - Effect: Allow
            Action:
            - s3:PutObject
            - s3:DeleteObject
            Resource:
            - !Sub arn:aws:s3:::${AWSSBInjectedLambdaZipsBucket}/*
  AWSSBInjectedCopyZipsLambda:
    Type: AWS::Lambda::Function
    Properties:
      Description: Copies objects from a source S3 bucket to a destination
      Handler: index.handler
      Runtime: python3.9
      Role: !GetAtt AWSSBInjectedCopyZipsRole.Arn
      Timeout: 240
      Code:
        ZipFile: |
          import json
          import logging
          import threading
          import boto3
          import cfnresponse


          def copy_objects(source_bucket, dest_bucket, prefix, objects):
              s3 = boto3.client('s3')
              for o in objects:
                  key = prefix + o
                  copy_source = {
                      'Bucket': source_bucket,
                      'Key': key
                  }
                  print('copy_source: %s' % copy_source)
                  print('dest_bucket = %s' % dest_bucket)
                  print('key = %s' % key)
                  s3.copy_object(CopySource=copy_source, Bucket=dest_bucket, Key=key)


          def delete_objects(bucket, prefix, objects):
              s3 = boto3.client('s3')
              objects = {'Objects': [{'Key': prefix + o} for o in objects]}
              s3.delete_objects(Bucket=bucket, Delete=objects)


          def timeout(event, context):
              logging.error('Execution is about to time out, sending failure response to CloudFormation')
              cfnresponse.send(event, context, cfnresponse.FAILED, {}, None)


          def handler(event, context):
              timer = threading.Timer((context.get_remaining_time_in_millis() / 1000.00) - 0.5, timeout, args=[event, context])
              timer.start()
              print('Received event: %s' % json.dumps(event))
              status = cfnresponse.SUCCESS
              try:
                  source_bucket = event['ResourceProperties']['SourceBucket']
                  dest_bucket = event['ResourceProperties']['DestBucket']
                  prefix = event['ResourceProperties']['Prefix']
                  objects = event['ResourceProperties']['Objects']
                  if event['RequestType'] == 'Delete':
                      delete_objects(dest_bucket, prefix, objects)
                  else:
                      copy_objects(source_bucket, dest_bucket, prefix, objects)
              except Exception as e:
                  logging.error('Exception: %s' % e, exc_info=True)
                  status = cfnresponse.FAILED
              finally:
                  timer.cancel()
                  cfnresponse.send(event, context, status, {}, None)
  AWSSBInjectedGetCidrsRole:
    Condition: AutoCidrs
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Principal:
            Service:
            - lambda.amazonaws.com
          Action:
          - sts:AssumeRole
      Path: /
      Policies:
      - PolicyName: cfn_utility_get_cidrs
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Effect: Allow
            Action:
            - ec2:DescribeVpcs
            - ec2:DescribeSubnets
            - ec2:DescribeAvailabilityZones
            - logs:CreateLogGroup
            - logs:CreateLogStream
            - logs:PutLogEvents
            Resource: '*'
  AWSSBInjectedGetCidrsLambda:
    DependsOn: AWSSBInjectedCopyZips
    Condition: AutoCidrs
    Type: AWS::Lambda::Function
    Properties:
      Handler: lambda_function.handler
      Role:
        Fn::GetAtt:
        - AWSSBInjectedGetCidrsRole
        - Arn
      Code:
        S3Bucket: !Ref AWSSBInjectedLambdaZipsBucket
        S3Key: functions/get_cidrs/lambda_function.zip
      Runtime: python3.9
      Timeout: '60'
  AWSSBInjectedGetCidrs:
    Condition: AutoCidrs
    Type: AWS::CloudFormation::CustomResource
    Properties:
      ServiceToken: !GetAtt AWSSBInjectedGetCidrsLambda.Arn
      Qty: !Ref NumberOfAvailabilityZones
      VpcId: !Ref VpcId
      CidrSize: !Ref CidrSize
  AWSSBInjectedGetAzsRole:
    Condition: AutoAzs
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Principal:
            Service:
            - lambda.amazonaws.com
          Action:
          - sts:AssumeRole
      Path: /
      Policies:
      - PolicyName: cfn_utility_get_cidrs
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Effect: Allow
            Action:
            - ec2:DescribeAvailabilityZones
            - logs:CreateLogGroup
            - logs:CreateLogStream
            - logs:PutLogEvents
            Resource: '*'
  AWSSBInjectedGetAzsLambda:
    DependsOn: AWSSBInjectedCopyZips
    Condition: AutoAzs
    Type: AWS::Lambda::Function
    Properties:
      Handler: lambda_function.handler
      Role:
        Fn::GetAtt:
        - AWSSBInjectedGetAzsRole
        - Arn
      Code:
        S3Bucket: !Ref AWSSBInjectedLambdaZipsBucket
        S3Key: functions/get_azs/lambda_function.zip
      Runtime: python3.9
      Timeout: '60'
  AWSSBInjectedGetAzs:
    Condition: AutoAzs
    Type: AWS::CloudFormation::CustomResource
    Properties:
      ServiceToken: !GetAtt AWSSBInjectedGetAzsLambda.Arn
      Qty: !Ref NumberOfAvailabilityZones
  AWSSBInjectedGeneratePasswordRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Principal:
            Service:
            - lambda.amazonaws.com
          Action:
          - sts:AssumeRole
      Path: /
      Policies:
      - PolicyName: cfn_utility_get_cidrs
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Effect: Allow
            Action:
            - logs:CreateLogGroup
            - logs:CreateLogStream
            - logs:PutLogEvents
            Resource: '*'
  AWSSBInjectedGeneratePasswordLambda:
    DependsOn: AWSSBInjectedCopyZips
    Type: AWS::Lambda::Function
    Properties:
      Handler: lambda_function.handler
      Role:
        Fn::GetAtt:
        - AWSSBInjectedGeneratePasswordRole
        - Arn
      Code:
        S3Bucket: !Ref AWSSBInjectedLambdaZipsBucket
        S3Key: functions/generate_password/lambda_function.zip
      Runtime: python3.6
      Timeout: '60'
  AWSSBInjectedGeneratePassword:
    Type: AWS::CloudFormation::CustomResource
    Properties:
      ServiceToken: !GetAtt AWSSBInjectedGeneratePasswordLambda.Arn
      Length: 32
  AWSSBInjectedGenerateDBNameRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Principal:
            Service:
            - lambda.amazonaws.com
          Action:
          - sts:AssumeRole
      Path: /
      Policies:
      - PolicyName: cfn_utility_get_cidrs
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Effect: Allow
            Action:
            - logs:CreateLogGroup
            - logs:CreateLogStream
            - logs:PutLogEvents
            Resource: '*'
  AWSSBInjectedGenerateDBNameLambda:
    DependsOn: AWSSBInjectedCopyZips
    Type: AWS::Lambda::Function
    Properties:
      Handler: lambda_function.handler
      Role:
        Fn::GetAtt:
        - AWSSBInjectedGenerateDBNameRole
        - Arn
      Code:
        S3Bucket: !Ref AWSSBInjectedLambdaZipsBucket
        S3Key: functions/generate_dbname/lambda_function.zip
      Runtime: python3.6
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



