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

(core): corssRegionReferences weak reference #22842

Closed
2 tasks
Tietew opened this issue Nov 9, 2022 · 3 comments
Closed
2 tasks

(core): corssRegionReferences weak reference #22842

Tietew opened this issue Nov 9, 2022 · 3 comments
Labels
@aws-cdk/core Related to core CDK functionality effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. p1

Comments

@Tietew
Copy link
Contributor

Tietew commented Nov 9, 2022

Describe the feature

corssRegionReferences is awesome feature.

I want a weak reference which can be updated or deleted even if it's used.

Use Case

Lambda@Edge requires Version ARN which is modified when the code is modified.

When I use crossRegionReferences with Lambda@Edge, updating code is rejected by ExportsWriter:

Exports cannot be updated: at throwIfAnyInUse

Example stacks:

#!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import * as lambda from 'aws-cdk-lib/aws-lambda'
import * as nodejs from 'aws-cdk-lib/aws-lambda-nodejs'

const app = new cdk.App();
const us = new cdk.Stack(app, 'CdkTest1', {
  env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'us-east-1' },
  crossRegionReferences: true,
});
const ja = new cdk.Stack(app, 'CdkTest2', {
  env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'ap-northeast-1' },
  crossRegionReferences: true,
});

// Lambda@Edge function in us-east-1
const func = new nodejs.NodejsFunction(us, 'Func', {
  entry: 'lib/func.ts',
  currentVersionOptions: { removalPolicy: cdk.RemovalPolicy.RETAIN },
});

// CloudFront distribution in ap-northeast-1
new cdk.CfnOutput(ja, 'FuncArn', {
  value: func.currentVersion.edgeArn,
});

When lib/func.ts is not modified, the stack CdkTest2 will be updated successfully.

When lib/func.ts is modified, func.currentVersion is modified.
The deployment of CdkStack1 (us-east-1) will be failed.

Proposed Solution

Skip check in ExportsWriter when weak reference.

ALL cross-region exports are weak:

new Stack(app, 'ExportStack', { crossRegionWeakReferences: true });

Only specific resources are weak:

class ExportStack extends Stack {
  constructor(...) {
    const func = new lambda.Function(this, ...);
    this.weakReference(func);
  }
}

Other Information

No response

Acknowledgements

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

CDK version used

2.50.0

Environment details (OS name and version, etc.)

Linux

@Tietew Tietew added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 9, 2022
@github-actions github-actions bot added the @aws-cdk/core Related to core CDK functionality label Nov 9, 2022
@rix0rrr
Copy link
Contributor

rix0rrr commented Nov 9, 2022

Good call! Thanks for testing it out! We'll have to noodle a bit on how this is going to integrate into a bigger proposal for weak references, but we'll get back to it.

@rix0rrr rix0rrr added effort/medium Medium work item – several days of effort p1 and removed needs-triage This issue or PR still needs to be triaged. labels Nov 9, 2022
@rix0rrr rix0rrr removed their assignment Nov 9, 2022
@rix0rrr rix0rrr added effort/large Large work item – several weeks of effort and removed effort/medium Medium work item – several days of effort labels Nov 9, 2022
@MrArnoldPalmer
Copy link
Contributor

Closing as a duplicate, we are tracking this in the RFC here aws/aws-cdk-rfcs#82

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

No branches or pull requests

3 participants