templates/fncm-cmis-deploy.yaml [197:275]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
              workingDirectory: '/home/ec2-user'
          - action: 'aws:runShellScript'
            name: setPVPermissionsAndOwnership
            maxAttempts: 3
            onFailure: Abort
            inputs:
              runCommand:
                - !Join
                  - ' '
                  - - '"chown"'
                    - '-R 50001:root /data'
                    - ';'
                    - '"chmod"'
                    - '-R 775 /data'
              workingDirectory: '/home/ec2-user'
  ExecuteMountPVandConfigDocumentsLambda:
    Type: 'AWS::Lambda::Function'
    DependsOn:
      - MountPVandConfigDocuments
    Properties:
      Handler: index.lambda_handler
      Runtime: python3.7
      Code:
        ZipFile: !Join
          - |+

          - - import boto3
            - 'import os, time,json'
            - import cfnresponse
            - import logging
            - ''
            - 'def lambda_handler(event, context):'
            - '    print(''Received event: %s'' % json.dumps(event))'
            - '    status = cfnresponse.SUCCESS'
            - '    try:'
            - '        if event[''RequestType''] == ''Delete'':'
            - '            cfnresponse.send(event, context, status, {})'
            - '        else:'
            - '            ssm = boto3.client(''ssm'')'
            - ''
            - '            asg = boto3.client(''autoscaling'')'
            - '            asg_name = event[''ResourceProperties''][''BastionASGName'']'
            - '            responseAsg = asg.describe_auto_scaling_groups(AutoScalingGroupNames=[asg_name])'
            - '            instanceId = responseAsg[''AutoScalingGroups''][0][''Instances''][0][''InstanceId'']'
            - '            ssmDocument = event[''ResourceProperties''][''SSMDocument'']'
            - '            responseData = {}'
            - ''
            - '            response=ssm.send_command('
            - '                InstanceIds = [instanceId],'
            - '                DocumentName=ssmDocument,'
            - '                TimeoutSeconds=3600,'
            - '                Comment=''Mount PVs and copy configuration files'','
            - '                CloudWatchOutputConfig={''CloudWatchOutputEnabled'': True, ''CloudWatchLogGroupName'': ''QuickStartLogs''},'
            - '                MaxConcurrency=''50'','
            - '                MaxErrors=''5'','
            - '            )'
            - ''
            - '            cmdId = response[''Command''][''CommandId'']'
            - '            responseData[''CommandId''] = cmdId'
            - '            print(''Started object creation in CommandId: '' + cmdId)'
            - '            print(''Bastion Host Instance: '' + instanceId)'
            - '            cfnresponse.send(event, context, cfnresponse.SUCCESS, responseData)'
            - '    except Exception as e:'
            - '        logging.error(''Exception: %s'' % e, exc_info=True)'
            - '        status = cfnresponse.FAILED'
            - '        cfnresponse.send(event, context, status, {}, None)'
      Description: Executes PV creation and mount script on Bastion host
      MemorySize: 320
      Timeout: 180
      Role: !Ref FNCMSSMSendCommandLambdaRoleARN
  ExecuteConfigObjectsDocuments:
    Type: 'Custom::ExecuteConfigObjectsDocument'
    Version: '1.0'
    Properties:
      ServiceToken: !GetAtt
        - ExecuteMountPVandConfigDocumentsLambda
        - Arn
      SSMDocument: !Ref MountPVandConfigDocuments
      BastionASGName: !Ref BastionASGName
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



templates/fncm-crs-deploy.yaml [210:288]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
              workingDirectory: '/home/ec2-user'
          - action: 'aws:runShellScript'
            name: setPVPermissionsAndOwnership
            maxAttempts: 3
            onFailure: Abort
            inputs:
              runCommand:
                - !Join
                  - ' '
                  - - '"chown"'
                    - '-R 50001:root /data'
                    - ';'
                    - '"chmod"'
                    - '-R 775 /data'
              workingDirectory: '/home/ec2-user'
  ExecuteMountPVandConfigDocumentsLambda:
    Type: 'AWS::Lambda::Function'
    DependsOn:
      - MountPVandConfigDocuments
    Properties:
      Handler: index.lambda_handler
      Runtime: python3.7
      Code:
        ZipFile: !Join
          - |+

          - - import boto3
            - 'import os, time,json'
            - import cfnresponse
            - import logging
            - ''
            - 'def lambda_handler(event, context):'
            - '    print(''Received event: %s'' % json.dumps(event))'
            - '    status = cfnresponse.SUCCESS'
            - '    try:'
            - '        if event[''RequestType''] == ''Delete'':'
            - '            cfnresponse.send(event, context, status, {})'
            - '        else:'
            - '            ssm = boto3.client(''ssm'')'
            - ''
            - '            asg = boto3.client(''autoscaling'')'
            - '            asg_name = event[''ResourceProperties''][''BastionASGName'']'
            - '            responseAsg = asg.describe_auto_scaling_groups(AutoScalingGroupNames=[asg_name])'
            - '            instanceId = responseAsg[''AutoScalingGroups''][0][''Instances''][0][''InstanceId'']'
            - '            ssmDocument = event[''ResourceProperties''][''SSMDocument'']'
            - '            responseData = {}'
            - ''
            - '            response=ssm.send_command('
            - '                InstanceIds = [instanceId],'
            - '                DocumentName=ssmDocument,'
            - '                TimeoutSeconds=3600,'
            - '                Comment=''Mount PVs and copy configuration files'','
            - '                CloudWatchOutputConfig={''CloudWatchOutputEnabled'': True, ''CloudWatchLogGroupName'': ''QuickStartLogs''},'
            - '                MaxConcurrency=''50'','
            - '                MaxErrors=''5'','
            - '            )'
            - ''
            - '            cmdId = response[''Command''][''CommandId'']'
            - '            responseData[''CommandId''] = cmdId'
            - '            print(''Started object creation in CommandId: '' + cmdId)'
            - '            print(''Bastion Host Instance: '' + instanceId)'
            - '            cfnresponse.send(event, context, cfnresponse.SUCCESS, responseData)'
            - '    except Exception as e:'
            - '        logging.error(''Exception: %s'' % e, exc_info=True)'
            - '        status = cfnresponse.FAILED'
            - '        cfnresponse.send(event, context, status, {}, None)'
      Description: Executes PV creation and mount script on Bastion host
      MemorySize: 320
      Timeout: 180
      Role: !Ref FNCMSSMSendCommandLambdaRoleARN
  ExecuteConfigObjectsDocuments:
    Type: 'Custom::ExecuteConfigObjectsDocument'
    Version: '1.0'
    Properties:
      ServiceToken: !GetAtt
        - ExecuteMountPVandConfigDocumentsLambda
        - Arn
      SSMDocument: !Ref MountPVandConfigDocuments
      BastionASGName: !Ref BastionASGName
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



