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

[apigateway] Add validations to the 'variables' property on Stage resource #3635

Closed
1 of 5 tasks
igilham opened this issue Aug 13, 2019 · 3 comments · Fixed by #25267
Closed
1 of 5 tasks

[apigateway] Add validations to the 'variables' property on Stage resource #3635

igilham opened this issue Aug 13, 2019 · 3 comments · Fixed by #25267
Assignees
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2

Comments

@igilham
Copy link
Contributor

igilham commented Aug 13, 2019

  • I'm submitting a ...

    • 🪲 bug report
    • 🚀 feature request
    • 📚 construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the current behavior?

API Gateway Stage variables must match a regex to be valid (See the documentation). When adding variables using CDK, this regex is not enforced, so it can synthesize a CloudFormation template that cannot be deployed.

    // const myFunction: IFunction;

    const versionAlias = lambda.Version.fromVersionAttributes(this, 'VersionInfo', {
        lambda: myFunction,
        version: '${stageVariables.lambdaAlias}'
    });

    const api: apiGateway.RestApi = new apiGateway.LambdaRestApi(this, 'RestApi', {
        restApiName: 'my-test-api',
        handler: versionAlias,
        deployOptions: {
          variables: {
            lambdaAlias: myFunction.latestVersion // == '$LATEST'
          }
        }
      });
  • What is the expected behavior (or behavior of feature suggested)?

CDK could throw an error if the variable values do not match the regex, preventing invalid templates from being created.

  • What is the motivation / use case for changing the behavior or adding this feature?

In a Blue/Green Deployment use case, I might have blue, green and production stages on my RestAPI, using Stage variables to define which Lambda alias each stage integrates with. It is currently illegal to use the $LATEST alias in a Stage variable.

  • Please tell us about your environment:

    • CDK CLI Version: 1.3.0
    • Module Version: @aws-cdk/aws-apigateway@1.3.0
    • OS: OSX Mojave 10.14.5
    • Language: TypeScript
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)

@igilham igilham added the needs-triage This issue or PR still needs to be triaged. label Aug 13, 2019
@eladb eladb self-assigned this Aug 13, 2019
@NGL321 NGL321 added package/cfn Related to the CFN layer (L1) feature-request A feature should be added or improved. @aws-cdk/aws-apigateway Related to Amazon API Gateway and removed needs-triage This issue or PR still needs to be triaged. labels Aug 13, 2019
@eladb eladb removed the package/cfn Related to the CFN layer (L1) label Aug 28, 2019
@eladb eladb assigned nija-at and unassigned eladb Sep 3, 2019
@nija-at nija-at changed the title API Gateway Stage variables should enforce the regex requirement [apigateway] Add validations to the 'variables' property on Stage resource Oct 21, 2019
@nija-at nija-at added the effort/small Small work item – less than a day of effort label Feb 13, 2020
@nija-at nija-at added the p2 label Aug 25, 2020
@github-actions
Copy link

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jun 17, 2022
@igilham
Copy link
Contributor Author

igilham commented Jun 22, 2022

Perhaps this should be documented as a known limitation if there's not enough interest to work on it?

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jun 22, 2022
@TheRealAmazonKendra TheRealAmazonKendra added the good first issue Related to contributions. See CONTRIBUTING.md label Jan 25, 2023
@sumupitchayan sumupitchayan self-assigned this Apr 20, 2023
@mergify mergify bot closed this as completed in #25267 May 2, 2023
mergify bot pushed a commit that referenced this issue May 2, 2023
…esource (#25267)

Closes #3635 

From the original issue: API Gateway Stage variables must match a regex to be valid ([See the documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html#cfn-apigateway-stage-variables)). When adding variables using CDK, this regex is not enforced, so it can synthesize a CloudFormation template that cannot be deployed.

This PR fixes this issue by adding a validation that the strings match that regex along with a unit test for these changes.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented May 2, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants