Skip to content
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

Can't use DependsOn stage with dynamic stages as parameter #1615

Closed
Ownmarc opened this issue Jun 9, 2020 · 3 comments
Closed

Can't use DependsOn stage with dynamic stages as parameter #1615

Ownmarc opened this issue Jun 9, 2020 · 3 comments
Labels
area/intrinsics Ref, If, Sub, GetAtt, ... stage/needs-investigation Requires a deeper investigation

Comments

@Ownmarc
Copy link

Ownmarc commented Jun 9, 2020

Description:

I have been trying to "DependsOn" the stage creation of my AWS::Serverless::Api, but it does not work in a way that let me change the stage with parameters

Steps to reproduce the issue:

Lets say I have this:

Parameters:
  ParamStage:
    Type: String
    Default: dev
    AllowedValues:
      - dev
      - prod

Resources:
  myApi:
    Type: AWS::Serverless::Api
    Properties:
      Name: myApi
      StageName: !Ref ParamStage

Then I want something to be created when the Stage of myApi is created (so I can't just DependsOn myApi, it needs to wait for its stage to be created)

So, based on #313 here is what I tried that did not work :

ApiUsagePlanKey:
    Type: "AWS::ApiGateway::UsagePlanKey"
    DependsOn: 
      - myApi.Stage #doesn't work, it can't resolve it
      - !Sub "myApi${ParamStage}Stage" #doesn't work, it says DependsOn needs a String
      - myApidevStage #works, but this is not using my ParamStage and will not work when I use "prod" ParamStage

    Properties:
      KeyId: !Ref myApiKey
      KeyType: API_KEY
      UsagePlanId: !Ref ApiUsagePlan

Observed result:

Unresolved resource dependencies [myApi.Stage] in the Resources block of the template
Template format error: Every DependsOn value must be a string

Expected result:

That the Api wait for stage to be created or that we have a way to access the stage or that I can construct a string for DependsOn

@Ownmarc
Copy link
Author

Ownmarc commented Feb 8, 2022

Hello, any update on this ?

Thanks

@hoffa
Copy link
Contributor

hoffa commented Oct 17, 2022

You might be able to get this to work by adding AWS::LanguageExtensions to Transform as such:

Transform:
  - AWS::LanguageExtensions
  - AWS::Serverless-2016-10-31

AWS::LanguageExtensions resolves intrinsic functions if the value is known when Transforms are run.

See #2533 for more information.

@hoffa
Copy link
Contributor

hoffa commented Nov 3, 2022

Closing in favor of #2533.

@hoffa hoffa closed this as completed Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/intrinsics Ref, If, Sub, GetAtt, ... stage/needs-investigation Requires a deeper investigation
Projects
None yet
Development

No branches or pull requests

5 participants