- Newest
- Most votes
- Most comments
While it's understandable that you want to use API Gateway as a backend for a custom resource in AWS CloudFormation, this approach is not directly supported. Custom resources in CloudFormation are designed to work primarily with AWS Lambda functions or Amazon Simple Notification Service (SNS) topics as service tokens.
The "Invalid service token" error you're encountering is because CloudFormation expects the service token to be either a Lambda function ARN or an SNS topic ARN. API Gateway's path ARN doesn't meet this requirement.
To achieve your goal, you would need to create an intermediary Lambda function that acts as the custom resource provider. This Lambda function can then integrate with your API Gateway endpoint. Here's a high-level approach:
- Create a Lambda function that will serve as the custom resource provider.
- Configure this Lambda function to make the necessary calls to your API Gateway endpoint.
- Use the Lambda function's ARN as the service token in your CloudFormation template for the custom resource.
This way, you can indirectly use API Gateway as part of your custom resource logic while adhering to CloudFormation's requirements for service tokens. The Lambda function will act as a bridge between CloudFormation and your API Gateway endpoint.
Remember that when working with custom resources, it's crucial to properly handle create, update, and delete events, and to send appropriate responses back to CloudFormation to ensure your stack operations complete successfully.
Sources
Amazon API Gateway concepts - Amazon API Gateway
Amazon API Gateway Features | API Management | Amazon Web Services
Relevant content
- AWS OFFICIALUpdated 2 months ago
