-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intrinsic Function !Join
does not work on DependsOn
property
#259
Comments
Hey, so the stage resource name you are constructing is not a hack. That's how SAM constructs stage names and we won't change that behavior in future. We have documented this here. Changing a resource's name would make CloudFormation delete/re-create the resource. So SAM will never change the resource naming structure. DependsOn does not work with intrinsic functions. This is a CloudFormation limitation that SAM cannot unfortunately circumvent. We are working on two things that will fix the problem for you:
At the moment, I think you should continue using the DependsOn approach without the worry that this is a hack. |
I also found out, that the logical ID of a stage is the concatenation This is why the following works for me. My Api has the logical name ...
Parameters:
ApiKeyId:
Description: "The ID of an existing ApiKey"
Type: String
ApiName:
Description: "The Name of the Api"
Type: String
StageName:
Description: "The stage to be deployed to"
Type: String
Default: production
Resources:
FooFunction:
Type: AWS::Serverless::Function
...
Api:
Type: AWS::Serverless::Api
Properties:
Name: !Ref ApiName
StageName: !Ref StageName
DefinitionBody:
swagger: "2.0"
schemes:
- "https"
paths:
'/scaled':
get:
responses: {}
x-amazon-apigateway-integration:
uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${FooFunction.Arn}/invocations
passthroughBehavior: "when_no_match"
httpMethod: "POST"
type: aws_proxy
security:
- api_key: []
securityDefinitions:
api_key:
type: "apiKey"
name: "x-api-key"
in: "header"
x-amazon-apigateway-api-key-source : "HEADER"
ServiceUsagePlan:
Type: "AWS::ApiGateway::UsagePlan"
DependsOn: ApiStage
Properties:
ApiStages:
- ApiId:
Ref: Api
Stage: !Ref StageName
ServiceUsagePlanKey:
Type: "AWS::ApiGateway::UsagePlanKey"
DependsOn: ServiceUsagePlan
Properties :
KeyId: !Ref ApiKeyId
KeyType: API_KEY
UsagePlanId:
Ref: ServiceUsagePlan
... |
Workaround This seems to work.
|
Hey Guys,
I have the following SAM configuration, which works quite well so far:
Please notice, that its only working, because I'm using the undocumented "feature" (or should I say hack?) as recommended here.
So have a closer look at this part:
Note, that the Resource
ServerlessServicetestStage
seems to be newly created by SAM (or what ever) and is never specified in the yaml file. Its very unintuitive to come up with this Resource name! Its really not nice, but as long as it works I don't complain.But here is my issue: as I want to make the stage
test
at least a bit more flexible I tried to utilize the!Join
intrinsic function.Which fails with
The ultimate goal is to achieve this:
It seems that
!Join
does not work onDependsOn
.I have the feeling that I'm failing to do a dirty workaround of an even dirtier workaround. What am I missing? What is the cleanest way to have a parameter like this:
And use
!Sub ${StageName}
where a Stage Name is needed?I read #32 and #97. Both got closed without a proper solution of the issue that a UsagePlan is depending on an APIGateway. Help is very appreciated.
The text was updated successfully, but these errors were encountered: