-
Notifications
You must be signed in to change notification settings - Fork 4.5k
cloudfront: experimental.EdgeFunction does not propagate tags correctly to stack #35512
Copy link
Copy link
Closed
Labels
@aws-cdk/aws-cloudfrontRelated to Amazon CloudFrontRelated to Amazon CloudFrontbugThis issue is a bug.This issue is a bug.effort/mediumMedium work item – several days of effortMedium work item – several days of effortp1
Description
Describe the bug
When creating a stack in eu-west-1 and using a cloudfront.experimental.EdgeFunction, a nested stack is created for the edge lambda in us-east-1. Cross stack references are set up correctly with parameters, but tags applied on the parent stack are not applied to the nested stack and its children.
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Library Version
No response
Expected Behavior
Expectation: a nested stack is created in us-east-1 with the tags from the parent stack.
Current Behavior
Actual: a nested stack is created in us-east-1 without any tags.
Reproduction Steps
Code example:
// stack.ts
export class SupportRedirectStack extends Stack {
constructor(scope: Construct, id: string, props: Props) {
super(scope, id, props);
const redirectMappingKeyValueStore = new cloudfront.KeyValueStore(
this,
'support-redirect-mapping' + Date.now(),
{
source: cloudfront.ImportSource.fromAsset(
join(__dirname, 'assets', 'data.json')
),
}
);
const redirectSupportFunction = new Function(
this,
'RedirectSupportFunction',
{
code: FunctionCode.fromFile({
filePath: join(
__dirname,
'functions',
'function.js'
),
}),
keyValueStore: redirectMappingKeyValueStore,
}
);
const redirectSupportEdgeLambda = new cloudfront.experimental.EdgeFunction(
this,
'RedirectSupportEdgeLambda',
{
code: Code.fromAsset(
join(__dirname, 'blabla')
),
handler: 'index.handler',
runtime: Runtime.NODEJS_22_X,
}
);
new Distribution(this, 'SupportRedirectDistribution', {
defaultBehavior: {
allowedMethods: AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
cachePolicy: CachePolicy.CACHING_DISABLED,
edgeLambdas: [
{
eventType: LambdaEdgeEventType.ORIGIN_REQUEST,
functionVersion: redirectSupportEdgeLambda,
},
],
functionAssociations: [
{
eventType: FunctionEventType.VIEWER_REQUEST,
function: redirectSupportFunction,
},
],
origin: new HttpOrigin(props.config.supportFqdn, {
customHeaders: {
origin: 'blabla',
},
}),
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
},
});
}
}
// bin.ts
const tags = {
ApplicationServiceID: 'ASID0001234',
};
new SupportRedirectStack(app, 'SupportRedirectStack', {
config,
env: {
account: CDK_DEFAULT_ACCOUNT,
region: CDK_DEFAULT_REGION,
},
tags,
});Possible Solution
No response
Additional Information/Context
No response
AWS CDK Library version (aws-cdk-lib)
2.214.0
AWS CDK CLI version
2.1029.1
Node.js Version
20.11.0
OS
macOS Apple Silicon
Language
TypeScript
Language Version
No response
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-cloudfrontRelated to Amazon CloudFrontRelated to Amazon CloudFrontbugThis issue is a bug.This issue is a bug.effort/mediumMedium work item – several days of effortMedium work item – several days of effortp1