Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apigateway: Use existing RestAPI to create CloudFront distribution #32332

Open
1 of 2 tasks
cyberworkz opened this issue Nov 29, 2024 · 0 comments
Open
1 of 2 tasks

apigateway: Use existing RestAPI to create CloudFront distribution #32332

cyberworkz opened this issue Nov 29, 2024 · 0 comments
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.

Comments

@cyberworkz
Copy link

cyberworkz commented Nov 29, 2024

Describe the feature

Current AWS CDK does not give the possibility to use an existing RestAPI (RestApiBase) to create a stack for Cloudfront distributions. Add a static method to RestApiBase to refer to an existing RestApi and a certain stage.

Use Case

I have some existing RestApi's in the API Gateway. I want to use a Cloudfront distribution for them and use AWS CDK to create these distributions.

Proposed Solution

The current code is missing fields to properly determine all necessary info. Include stage-name for creating a RestApiBase will probably help.

This code fails:

let restApi: apigateway.RestApiBase = apigateway.RestApi.fromRestApiId(this, props.name, props.restApiId) as apigateway.RestApiBase;
        
        new cloudfront.Distribution(this, props.name, {
            defaultBehavior: {
                origin: new cdk.aws_cloudfront_origins.RestApiOrigin(restApi,
                    {
                        originPath: '/home',
                    },
                ),
                allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,

Other Information

I am trying to use a proxy-lambda with apigateway integration to connect to a cloudfront distribution.

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.171.0

Environment details (OS name and version, etc.)

Apple M1 Max Macos Sequoia 15.1.1 (24B91)

@cyberworkz cyberworkz added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 29, 2024
@github-actions github-actions bot added the @aws-cdk/aws-apigateway Related to Amazon API Gateway label Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant