# Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. # A copy of the License is located at # # http://www.apache.org/licenses/LICENSE-2.0 # # or in the "license" file accompanying this file. This file is distributed # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either # express or implied. See the License for the specific language governing # permissions and limitations under the License. --- AWSTemplateFormatVersion: 2010-09-09 Transform: AWS::Serverless-2016-10-31 Parameters: SAMExtensionBucketsPrefix: Type: String TestServerlessFunctionPackagePath: Type: String TestApiDefinitionPath: Type: String TestHttpApiDefinitionPath: Type: String TestStateMachineDefinitionPath: Type: String Resources: TestLambda: Type: AWS::Serverless::Function Properties: Handler: index.handler Runtime: python3.10 CodeUri: Bucket: !Sub "${SAMExtensionBucketsPrefix}-${AWS::Region}" Key: !Ref TestServerlessFunctionPackagePath # Hint: There is currently a bug when using AWS::Serverless::Application with !Sub. It will always complain with # As a mitigation we will use standard AWS::CloudFormation::Stack. Always open for mitigations. :-) # Error: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [ServerlessApplication] is invalid. Resource is missing the required [ApplicationId] property. # ServerlessApplication: # Type: AWS::CloudFormation::Stack # Properties: # TemplateURL: !Sub "https://s3.amazonaws.com/${SAMExtensionBucketsPrefix}-${AWS::Region}/${ServerlessApplicationTemplatePath}" # Parameters: # ExampleParameter: "ExampleValue" TestApi: Type: AWS::Serverless::Api Properties: StageName: dev DefinitionUri: Bucket: !Sub "${SAMExtensionBucketsPrefix}-${AWS::Region}" Key: !Ref TestApiDefinitionPath TestHttpApi: Type: AWS::Serverless::HttpApi Properties: StageName: dev DefinitionUri: Bucket: !Sub "${SAMExtensionBucketsPrefix}-${AWS::Region}" Key: !Ref TestHttpApiDefinitionPath TestStateMachine: Type: AWS::Serverless::StateMachine Properties: Policies: - LambdaInvokePolicy: FunctionName: "FUNCTION_NAME" - LambdaInvokePolicy: FunctionName: "OnFirstMatch" - LambdaInvokePolicy: FunctionName: "OnSecondMatch" DefinitionUri: Bucket: !Sub "${SAMExtensionBucketsPrefix}-${AWS::Region}" Key: !Ref TestStateMachineDefinitionPath