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: Incorrect cross-stack reference #26043

Closed
mng-imstsvc opened this issue Jun 19, 2023 · 2 comments
Closed

core: Incorrect cross-stack reference #26043

mng-imstsvc opened this issue Jun 19, 2023 · 2 comments
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. duplicate This issue is a duplicate.

Comments

@mng-imstsvc
Copy link

mng-imstsvc commented Jun 19, 2023

Describe the bug

This is similar to #18882

When using a cross-stack reference in a Source.data string, the reference is not properly resolved.

Reproduction Steps

Here is a minimal example reproducing the issue:

import * as cdk from "aws-cdk-lib";
import * as s3 from "aws-cdk-lib/aws-s3";
import * as s3deploy from "aws-cdk-lib/aws-s3-deployment";

const app = new cdk.App();

/**
 * StackA consists of a bucket.
 */
const stackA = new cdk.Stack(app, "StackA");
const stackAbucket = new s3.Bucket(stackA, "StackABucket", {
    removalPolicy: cdk.RemovalPolicy.DESTROY,
});


/**
 * StackB depends on the bucket created in StackA.
 */
const stackB = new cdk.Stack(app, "StackB");
const assetBucket = new s3.Bucket(stackB, 'AssetBucket', {
    publicReadAccess: false,
});

new s3deploy.BucketDeployment(stackB, "StackBBucketDeployment", {
    sources: [s3deploy.Source.data("test.txt", "The name of the stackA bucket is " + stackAbucket.bucketName)],
    destinationBucket: assetBucket,
});

Expected Behavior

cdk synth StackB should output something like:

    "SourceObjectKeys": [
     "0b8ed7084c2c566032fd832e4e1e54ea6c83b261fdf63942a1d2d5430c3ca1c7.zip"
    ],
    "SourceMarkers": [
     {
      "<<marker:0xbaba:0>>": {
       "Fn::ImportValue": "StackA:ExportsOutputRefStackABucketBucketNamexxxxxxxxxx"
      }
     }
    ],

Current Behavior

cdk synth StackB outputs:

    "SourceObjectKeys": [
     "0b8ed7084c2c566032fd832e4e1e54ea6c83b261fdf63942a1d2d5430c3ca1c7.zip"
    ],
    "SourceMarkers": [
     {
      "<<marker:0xbaba:0>>": {
       "Ref": "StackABucket5F1E7D39"
      }
     }
    ],

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.84.0 (build f7c792f)

Framework Version

No response

Node.js Version

v18.16.0

OS

WSL/Debian

Language

Typescript

Language Version

No response

Other information

No response

@mng-imstsvc mng-imstsvc added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 19, 2023
@github-actions github-actions bot added the @aws-cdk/core Related to core CDK functionality label Jun 19, 2023
@peterwoodworth peterwoodworth added duplicate This issue is a duplicate. and removed needs-triage This issue or PR still needs to be triaged. labels Jun 19, 2023
@peterwoodworth
Copy link
Contributor

Thanks, closing in favor of #22843. You can view this comment for a workaround #19257 (comment)

@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 bug This issue is a bug. duplicate This issue is a duplicate.
Projects
None yet
Development

No branches or pull requests

2 participants