Ok, previous question about using different lambda versions on different stages here: AWS - lambda versions to different gateway stages?
Now I'm trying to put it all together using AWS SAM cli but still getting an error:
template.yaml
Relevant parts of my template
Resources:
AppApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: HelloWorldApiGateway
HelloWorldResource:
Type: AWS::ApiGateway::Resource
Properties:
RestApiId: !Ref AppApi
ParentId: !GetAtt AppApi.RootResourceId
PathPart: hello-world
ResourceMethodGet:
Type: AWS::ApiGateway::Method
Properties:
AuthorizationType: NONE
RestApiId: !Ref AppApi
ResourceId: !Ref HelloWorldResource
HttpMethod: GET
Integration:
Type: AWS
IntegrationHttpMethod: GET
Uri: !Join
- ""
- - "arn:aws:apigateway:"
- ${AWS::Region}
- "lambda:path/2015-03-31/functions/"
- !GetAtt HelloWorldFunction.Arn
- ":${lambda_alias}"
- "/invocations"
ProductionStage:
Type: AWS::ApiGateway::Stage
Properties:
RestApiId: !Ref AppApi
StageName: production
DeploymentId: !Ref ProductionDeployment
Variables:
function_alias: production
StagingStage:
Type: AWS::ApiGateway::Stage
Properties:
RestApiId: !Ref AppApi
StageName: staging
DeploymentId: !Ref StagingDeployment
Variables:
function_alias: staging
ProductionDeployment:
Type: AWS::ApiGateway::Deployment
Properties:
RestApiId: !Ref AppApi
StagingDeployment:
Type: AWS::ApiGateway::Deployment
Properties:
RestApiId: !Ref AppApi
HelloWorldFunction:
Type: AWS::Serverless::Function
# ...
FunctionStagingAlias:
Type: AWS::Lambda::Alias
Properties:
FunctionName: !Ref HelloWorldFunction
Name: "staging"
FunctionVersion: $LATEST
FunctionProductionAlias:
Type: AWS::Lambda::Alias
Properties:
FunctionName: !Ref HelloWorldFunction
Name: "production"
FunctionVersion: 2 # Just an example
The error
sam build && sam sync --stack-name hello-world-app
CloudFormation events from stack operations (refresh every 0.5 seconds)
---------------------------------------------
ResourceStatus ResourceType LogicalResourceId ResourceStatusReason
---------------------------------------------
... non-error events ...
UPDATE_IN_PROGRESS AWS::ApiGateway::Method ResourceMethodGet -
UPDATE_FAILED AWS::ApiGateway::Method ResourceMethodGet AWS ARN for integration must
contain path or action (Service:
AmazonApiGateway; Status Code:
400; Error Code:
BadRequestException; Request ID:
7ea71b09-062b-41d3-89e1-e567c0cd3
85e; Proxy: null)
UPDATE_ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack hello-world-app The following resource(s) failed
to update: [ResourceMethodGet].
... rollback ...