redeploy_apigw.py 693 B

12345678910111213141516171819202122232425262728293031
  1. import boto3
  2. from crhelper import CfnResource
  3. from decorators import with_logging
  4. helper = CfnResource(json_logging=False, log_level="DEBUG", boto_level="CRITICAL")
  5. api_client = boto3.client("apigateway")
  6. @with_logging
  7. @helper.create
  8. @helper.delete
  9. def create(event, context):
  10. return None
  11. @with_logging
  12. @helper.update
  13. def update(event, context):
  14. props = event["ResourceProperties"]
  15. props_old = event["OldResourceProperties"]
  16. if props_old["DeployCognito"] != props["DeployCognito"]:
  17. api_client.create_deployment(
  18. restApiId=props["ApiId"], stageName=props["ApiStage"]
  19. )
  20. return None
  21. def handler(event, context):
  22. helper(event, context)