AWSTemplateFormatVersion: 2010-09-09 Parameters: S3BucketName: AllowedPattern: '^[0-9a-zA-Z]+([0-9a-zA-Z-]*[0-9a-zA-Z])*$' ConstraintDescription: >- Quick Start bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-). Description: >- S3 bucket name for the Quick Start assets. Quick Start bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-). Type: String S3KeyPrefix: AllowedPattern: '^[0-9a-zA-Z-/]*$' ConstraintDescription: >- Can include numbers, lowercase letters, uppercase letters, hyphens (-), and forward slash (/). Default: 'cfn-project/' Description: >- S3 key prefix where assets are located should end withforward slash (/). Type: String Resources: LambdaExecutionRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Principal: Service: - lambda.amazonaws.com Action: - sts:AssumeRole Path: "/" ManagedPolicyArns: - "arn:aws:iam::aws:policy/AWSLambdaExecute" GenRandomLambda: Type: AWS::Lambda::Function Properties: Description: Lambda creates simple random string Handler: lambda_function.handler Runtime: python3.7 Role: !GetAtt 'LambdaExecutionRole.Arn' Timeout: 300 Code: S3Bucket: !Ref 'S3BucketName' S3Key: !Sub '${S3KeyPrefix}lambda_functions/packages/GenRandom/lambda.zip' StringGenerator: DeletionPolicy: Retain Type: AWS::CloudFormation::CustomResource Properties: ServiceToken: !GetAtt GenRandomLambda.Arn Length: 12 Outputs: GeneratedRandomString: Value: !GetAtt StringGenerator.RandomString