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

RestApi Endpoint Output Name & Export #1611

Closed
aecollver opened this issue Jan 24, 2019 · 4 comments · Fixed by #1624
Closed

RestApi Endpoint Output Name & Export #1611

aecollver opened this issue Jan 24, 2019 · 4 comments · Fixed by #1624
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug.

Comments

@aecollver
Copy link

aecollver commented Jan 24, 2019

The Endpoint child created by RestApi doesn't seem usable because it has random characters appended to it (e.g. apiEndpoint9349E63C) and the exported name collides across multiple stack instances (I'm synthesizing the stack once in a build step and deploying multiple instances of it from CodePipeline).

Can we remove the Endpoint child construct so 1) I don't have to use findChild to disable exporting the output (see below) and 2) I don't have unnecessary stack outputs?

     const restApi = new api.RestApi(this, 'api', {
      restApiName: (new cdk.AwsStackName()) as any
    });
    // Don't export the stack output because it collides when multiple
    // CloudFormation stacks are created in one account.
    restApi.findChild('Endpoint')['export'] = undefined;

    new cdk.Output(this, 'Endpoint', {
      value: restApi.urlForPath(),
      disableExport: true
    });
@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 24, 2019

I think it makes more sense to disable exporting by default. Do you agree?

I see how the export in your case leads to conflicts. The presence of an output by itself shouldn't hurt, right?

@aecollver
Copy link
Author

I think it makes more sense to disable exporting by default. Do you agree?

Yes

The presence of an output by itself shouldn't hurt, right?

I imagine not in most cases, but it does contribute to the "60 outputs in a template" limit in CloudFormation (https://aws.amazon.com/cloudformation/faqs/#Limits_and_Restrictions).

That said, what is the use case for an output with random characters appended to it? In my case I wanted a stable output so it's easy to aggregate endpoints across stack instances (e.g. test, region 1, region 2).

@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 24, 2019

These are for human consumption, mostly. And the characters are random, but stable.

But point taken, I'll think about it some more.

@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 24, 2019

Dupe of #903

rix0rrr pushed a commit that referenced this issue Jan 28, 2019
Export names must be unique and can conflict, so automatically turning
every Output into an Export can lead to problems for customers who
deploy the same template multiple times. Especially when the outputs
are created for them and they have no control over them.

We'll turn Outputs into exports on-demand (when .makeImportValue() is
called).

Fixes #903, fixes #1611.
@eladb eladb added bug This issue is a bug. @aws-cdk/aws-apigateway Related to Amazon API Gateway labels Feb 4, 2019
rix0rrr added a commit that referenced this issue Feb 5, 2019
Export names must be unique and can conflict, so automatically turning
every Output into an Export can lead to problems for customers who
deploy the same template multiple times. Especially when the outputs
are created for them and they have no control over them.

We'll turn Outputs into exports on-demand (when .makeImportValue() is
called).

Fixes #903, fixes #1611.
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 bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants