Skip to content

Commit

Permalink
fix(cloudfront): EdgeFunction us-east-1 stack created in different ac…
Browse files Browse the repository at this point in the history
…count

The us-east-1 stack for EdgeFunction was defaulting to the default deploy
account. This means that using one account to deploy, and another for the stack
which contains the EdgeFunction, the support stack in us-east-1 will be deployed
into the deploy account, rather than stack account.

This fix has the us-east-1 stack inherit the account from the parent stack.

fixes #12789
  • Loading branch information
njlynch committed Feb 15, 2021
1 parent 2f5b2c3 commit 81caab9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ export class EdgeFunction extends Resource implements lambda.IVersion {
let edgeStack = stage.node.tryFindChild(edgeStackId) as Stack;
if (!edgeStack) {
edgeStack = new Stack(stage, edgeStackId, {
env: { region: EdgeFunction.EDGE_REGION },
env: {
region: EdgeFunction.EDGE_REGION,
account: Stack.of(this).account,
},
});
}
this.stack.addDependency(edgeStack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ describe('stacks', () => {
});
});

test('us-east-1 stack inherits account of parent stack', () => {
new cloudfront.experimental.EdgeFunction(stack, 'MyFn', defaultEdgeFunctionProps());

const fnStack = getFnStack();

expect(fnStack.account).toEqual('111111111111');
});

test('creates minimal constructs if scope region is us-east-1', () => {
app = new cdk.App();
stack = new cdk.Stack(app, 'Stack', {
Expand Down

0 comments on commit 81caab9

Please sign in to comment.