Which solution will meet these requirements?
Create a CodePipeline action immediately after the deployment stage of the API. Configure the action to invoke an AWS Lambda function. Configure the Lambda function to download the SDK from API Gateway, upload the SDK to the S3 bucket, and create a CloudFront invalidation for the SDK path.
Create a CodePipeline action immediately after the deployment stage of the API. Configure the action to use the CodePipeline integration with API Gateway to export the SDK to Amazon S3. Create another action that uses the CodePipeline integration with Amazon S3 to invalidate the cache for the SDK path.
Create an Amazon EventBridge rule that reacts to UpdateStage events from aws.apigateway. Configure the rule to invoke an AWS Lambda function to download the SDK from API Gateway, upload the SDK to the S3 bucket, and call the CloudFront API to create an invalidation for the SDK path.
Create an Amazon EventBridge rule that reacts to CreateDeployment events from aws.apigateway. Configure the rule to invoke an AWS Lambda function to download the SDK from API Gateway, upload the SDK to the S3 bucket, and call the S3 API to invalidate the cache for the SDK path.
Explanations:
This solution uses a CodePipeline action after the API deployment to invoke a Lambda function. The Lambda function can download the SDK from API Gateway, upload it to the S3 bucket, and create a CloudFront invalidation to ensure the updated SDK is available to clients.
CodePipeline integration with API Gateway does not directly support exporting the SDK to Amazon S3, nor does it support automatic cache invalidation in CloudFront. Therefore, an additional custom Lambda function would be necessary for the export and invalidation tasks.
EventBridge reacting toUpdateStageevents from API Gateway would not be the most appropriate trigger for this process. Also, using Lambda to call the CloudFront API for invalidation isn’t a best practice as this action would be better suited within the pipeline after deployment.
EventBridge reacting toCreateDeploymentevents from API Gateway would not be ideal for this task. While the Lambda function could perform the download and upload to S3, invalidating the cache using the S3 API is incorrect. CloudFront invalidation must be performed through CloudFront, not S3.