(apigateway): support deployment salting for imported RestApi
See original GitHub issueIf the RestApi is define by RestApi.fromRestApiAttributes(), any deployment will not add salt to the deployment resource.
Reproduction Steps
This is my code.
const api = RestApi.fromRestApiAttributes(this, 'ImportedApi', {
restApiId: XXX,
rootResourceId: XXX,
});
const allResources = api.root.addResource('cdk');
allResources.addCorsPreflight({ allowOrigins: Cors.ALL_ORIGINS });
const method = allResources.addMethod('PUT', ifn, {
methodResponses: [
{
statusCode: '200',
responseParameters: {
'method.response.header.Access-Control-Allow-Origin': true,
},
},
],
authorizationType: AuthorizationType.IAM,
});
// Handle deployment
const deployment = new Deployment(this, '123_deployment', {
api: RestApi.fromRestApiId(this, 'abc', apiCDKApiApiId),
});
new Stage(this, 'CDKApiStageDev', { deployment, stageName: `${ENV}` });
“taotest123deploymentC642C343” is the resource name in the Cloudformation template.
What did you expect to happen?
add salt to the resource name
What actually happened?
no salt was added to the resource name
Environment
- **CDK CLI Version :1.83
- Framework Version:
- Node.js Version:
- **OS :MAC
- **Language (Version):TypeScript
Other
WORKAROUND: Just in case anyone ran into the same problem, you can force a deployment by manually adding salt to deployment id. in above example, 123_deployment is my deployment id, you can change the id 1234_deployment to force new deployment to deploy.
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Reactions:14
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Deploy a REST API in API Gateway - AWS Documentation
Learn how to set up and manage API deployments in Amazon API Gateway. ... In API Gateway, a REST API deployment is represented...
Read more >salt.modules.boto_apigateway module
Connection module for Amazon APIGateway ... Create a new REST API Service with the given name ... Gets information about the defined API...
Read more >aws.apigateway.RestApi - Pulumi
To create and deploy WebSocket and HTTP APIs, use Amazon API Gateway Version 2 resources. !> WARN: When importing Open API Specifications with...
Read more >Amazon API Gateway vs Salt Security API Protection Platform
API Gateway integrates well with AWS Lambda. This allows us to build a web server in the language and framework of our choice,...
Read more >Serverless Import Apigateway
yml services and deploy each stack independently but share the same API Gateway stage/ REST API, then you want each service to use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @tmclaugh - I’m keen to explore your statement here.
The
addToLogicalId()
method is the key to determine when aDeployment
’s logical id should be modified. You can see all the uses of this method that tells the Deployment when it should be updated.Let’s take the simple case where a
RestApi
is defined in one stack along with a number of Resources and Methods, and later imported into another stack using theRestApi.fromRestApiAttributes()
where further Methods and Resources are defined. Unlessdeploy
is unset, the first stack would create aDeployment
construct set tolatestDeployment
. However, it would not be possible for thisDeployment
construct to know of the Methods and Resources in the second stack and therefore cannot correctly determine when its logical id should be mutated.How do you propose your approach tackle this case?
Hey Team,
I am using the below code which is working for me.
I am doing deployment two times to make it work. In the first deployment, it is creating resources and in the second deployment, it is updating stage.
This will be like