aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.59k stars 3.89k forks source link

Consolidated cross-account resource stack #7080

Closed CaerusKaru closed 2 years ago

CaerusKaru commented 4 years ago

Currently aws-codepipeline-actions has a utility that enables generating resources for cross-account deployments. It does this by creating a stack in the necessary account that the CDK can deploy to setup the resources for later use.

However, if people writing other constructs wish to take on likewise actions, for say cross-account DNS delegation, they are stuck needing to duplicate the logic for that package, leading to two separate stacks for the same account (with the same goal in mind – cross-account resources).

I'm proposing creating a utility, possibly a static method on the Stack class that can return the resource stack for cross-account/cross-region purposes.

Use Case

I'm writing a cross-account DNS domain delegation construct that would benefit from not duplicating this logic.

Proposed Solution

Something like this:

public static external(app: App, accountNumber: string, region: string): Stack;

Other


This is a :rocket: Feature Request

CaerusKaru commented 4 years ago

cc @skinny85 @eladb

eladb commented 4 years ago

I am trying to wrap my head around the proposed API. Can you provide a more complete example?

CaerusKaru commented 4 years ago

Something like this:

const otherAccountStack = Stack.external(this.node.root, '12345678', 'us-west-2');

const roleId = 'DelegateHostRole';
const hostRole: Role = otherAccountStack.node.tryFindChild(roleId) as Role | undefined || new Role(otherAccountStack, roleId, {...});
workeitel commented 4 years ago

EDIT: Sorry, that comment only made partially sense here. Moved it into a new issue https://github.com/aws/aws-cdk/issues/8776

github-actions[bot] commented 2 years ago

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.