Transform: AWS::Serverless-2016-10-31 Description: > Creates a CloudFormation custom resource used to retrieve properties of a Cloud9 instance. Globals: Function: Runtime: python3.7 Timeout: 180 Handler: index.lambda_handler Parameters: Nonce: Type: String Description: Forces custom resource to run everytime CF runs -- pass in a $RANDOM as a parameter Resources: LambdaFunction: Type: AWS::Serverless::Function Properties: FunctionName: lmd-csr-get-cloud9-attributes CodeUri: ./src Policies: - Statement: - Sid: CloudFormation Effect: Allow Action: - cloudformation:DescribeStackResource - cloud9:DescribeEnvironments Resource: '*' AttachLayer: Type: Custom::LayerAttachment Properties: LayerName: lyr-csr-common LambdaName: !Ref LambdaFunction #CloudFormation will not execute the custom resource if no properties are changed. #Along with the parameter, this ensures that the resource is called each time CloudFormation runs Nonce: !Ref Nonce ServiceToken: !ImportValue CFNAttachLambdaLayer Outputs: LambdaFunctionArn: Description: "Custom Resource to get properties of a Cloud 9 instance" Value: !GetAtt LambdaFunction.Arn Export: Name: CFNGetCloud9Properties