You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(not sure if this is a bug or by design, as CloudFormation works in the same way)
When an API Gateway CloudFormation stack is updated, it might make changes to the API Gateway resources. But in AWS these do not become active until the API Gateway is redeployed. Therefore it is needed that the API Gateway can also be redeployed using Ansible.
However, this does not happen. Looking at the codecreate_deployment() is called as part of the ensure_api_in_correct_state() function. In turn, this functional is only called from main() when api_id is None, meaning only for cases where no previous API exists.
I think any time a task of community.aws.api_gateway with api_id and stage is run, it should create a new deployment. Now the only way to work around this seems to run aws apigateway create-deployment --rest-api "{{ item }}" --stage-name "development" --region {{ aws_region }} --description "Deployment on {{ now() }}" as a shell command.
The the example the 1st task updates the API Gateway CloudFormation stack. The 2nd and 3rd task collect all the API Gateway IDs. The 4th task should redeploy the API Gateway.
Name: botoVersion: 2.49.0Summary: Amazon Web Services LibraryHome-page: https://github.com/boto/boto/Author: Mitch GarnaatAuthor-email: [email protected]License: MITLocation: /usr/local/lib/python3.11/site-packagesRequires: Required-by: ---Name: boto3Version: 1.34.35Summary: The AWS SDK for PythonHome-page: https://github.com/boto/boto3Author: Amazon Web ServicesAuthor-email: License: Apache License 2.0Location: /usr/local/lib/python3.11/site-packagesRequires: botocore, jmespath, s3transferRequired-by: ---Name: botocoreVersion: 1.34.35Summary: Low-level, data-driven core of boto 3.Home-page: https://github.com/boto/botocoreAuthor: Amazon Web ServicesAuthor-email: License: Apache License 2.0Location: /usr/local/lib/python3.11/site-packagesRequires: jmespath, python-dateutil, urllib3Required-by: boto3, s3transfer
Configuration
CONFIG_FILE() = NoneEDITOR(env: EDITOR) = sublPAGER(env: PAGER) = less
OS / Environment
MacOs
Steps to Reproduce
- name: Deploy API Gateway CloudFormation templateamazon.aws.cloudformation:
stack_name: api-gatewaystate: presentregion: "{{ aws_region }}"template: api-gateway.yamlcapabilities: CAPABILITY_NAMED_IAM
- name: Get API Gateway CloudFormation deploymentamazon.aws.cloudformation_info:
stack_name: api-gatewayregion: "{{ aws_region }}"stack_resources: trueregister: api_gateways
- name: Get the API Gatewaysset_fact:
api_gateways: "{{ api_gateways | community.general.json_query('cloudformation.* | [0].stack_resource_list[?resource_type==`AWS::ApiGateway::RestApi`].physical_resource_id') }}"
- name: Redeploy API gatewaycommunity.aws.api_gateway:
api_id: "{{ item }}"lookup: idstage: developmentregion: "{{ aws_region }}"deploy_desc: Deployment on {{ now() }}with_items: "{{ api_gateways }}"delay: 10loop_control:
label: Creating new deployment for API gateway {{ item }} on stage development
Expected Results
API Gateway is redeployed
Actual Results
No change to the deployment
Code of Conduct
I agree to follow the Ansible Code of Conduct
The text was updated successfully, but these errors were encountered:
danielvijge
changed the title
api_gateway doesn't create a new deployment is API Gateway already exists
api_gateway doesn't create a new deployment when API Gateway already exists
Feb 6, 2024
Summary
(not sure if this is a bug or by design, as CloudFormation works in the same way)
When an API Gateway CloudFormation stack is updated, it might make changes to the API Gateway resources. But in AWS these do not become active until the API Gateway is redeployed. Therefore it is needed that the API Gateway can also be redeployed using Ansible.
However, this does not happen. Looking at the code
create_deployment()
is called as part of theensure_api_in_correct_state()
function. In turn, this functional is only called frommain()
whenapi_id is None
, meaning only for cases where no previous API exists.I think any time a task of
community.aws.api_gateway
withapi_id
andstage
is run, it should create a new deployment. Now the only way to work around this seems to runaws apigateway create-deployment --rest-api "{{ item }}" --stage-name "development" --region {{ aws_region }} --description "Deployment on {{ now() }}"
as a shell command.The the example the 1st task updates the API Gateway CloudFormation stack. The 2nd and 3rd task collect all the API Gateway IDs. The 4th task should redeploy the API Gateway.
Issue Type
Bug Report
Component Name
api_gateway
Ansible Version
Collection Versions
AWS SDK versions
Configuration
OS / Environment
MacOs
Steps to Reproduce
Expected Results
API Gateway is redeployed
Actual Results
No change to the deployment
Code of Conduct
The text was updated successfully, but these errors were encountered: