-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
CodeBuild S3 cache doesn't generate ImportValue #3554
Labels
bug
This issue is a bug.
Comments
skinny85
added
bug
This issue is a bug.
and removed
needs-triage
This issue or PR still needs to be triaged.
labels
Aug 6, 2019
Thanks for opening the issue @rafalwrzeszcz . I can confirm I was able to reproduce the problem. Here's a minimal repro: import { App, Construct, Stack, StackProps } from '@aws-cdk/core';
import codebuild = require('@aws-cdk/aws-codebuild');
import s3 = require('@aws-cdk/aws-s3');
class Infrastructure extends Stack {
public readonly cacheBucket: s3.IBucket;
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
this.cacheBucket = new s3.Bucket(this, 'CacheBucket', {
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
});
}
}
export interface FrontendProps extends StackProps {
readonly cacheBucket: s3.IBucket;
}
class Frontend extends Stack {
constructor(scope: Construct, id: string, props: FrontendProps) {
super(scope, id, props);
new codebuild.PipelineProject(this, 'CheckoutProject', {
cache: codebuild.Cache.bucket(props.cacheBucket),
});
}
}
const app = new App();
const infrastructure = new Infrastructure(app, 'InfrastructureStack');
new Frontend(app, 'Frontend', {
cacheBucket: infrastructure.cacheBucket,
});
app.synth(); The relevant part of the Frontend template: "CheckoutProjectB8572A47": {
"Type": "AWS::CodeBuild::Project",
"Properties": {
"Artifacts": {
"Type": "CODEPIPELINE"
},
"Environment": {
"ComputeType": "BUILD_GENERAL1_SMALL",
"Image": "aws/codebuild/standard:1.0",
"PrivilegedMode": false,
"Type": "LINUX_CONTAINER"
},
"ServiceRole": {
"Fn::GetAtt": [
"CheckoutProjectRole5E13DE3D",
"Arn"
]
},
"Source": {
"Type": "CODEPIPELINE"
},
"Cache": {
"Location": {
"Fn::Join": [
"/",
[
{
"Ref": "CacheBucket41D9D0B0" // <--- this should be "Fn::ImportValue": "..."
},
{
"Ref": "AWS::NoValue"
}
]
]
},
"Type": "S3"
}
}, |
rix0rrr
added a commit
that referenced
this issue
Aug 7, 2019
References used in Fn.join() will now be properly substituted if they're cross-stack references. Fixes #3554.
mergify bot
pushed a commit
that referenced
this issue
Aug 7, 2019
References used in Fn.join() will now be properly substituted if they're cross-stack references. Fixes #3554.
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm submitting a ...
What is the current behavior?
I want to create a CodeBuild project that utilizes buckets from a different stack (I define buckets in
InfrastructureStack
and then have a CodeBuild project inFrontendStack
). For all of the references to those buckets CDK generatesImportValue
statements, except forCache
- it creates aRef
call with just a resource ID from another stack (same bucket is used inFrontendStack
to generate IAM policy and there anImportValue
is generated).My
InfrastructureStack
Kotlin source:My FrontendStack:
And this is a coupling part:
Note that there are two buckets, both created and passed the same way, and even the
cacheBucket
reference is inserted as import value into IAM policy, theartifactsBucket
reference is inserted also as import value into artifacts store definition. But cache definition of CodeBuild is created asRef
:I even tried to create a Bucket reference using
Bucket.fromBucketArn
, but this is what is generated:What is the expected behavior (or behavior of feature suggested)?
S3 cache for CodeBuild will contain cross-stack reference not a resource ID reference.
Please tell us about your environment:
The text was updated successfully, but these errors were encountered: