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

Multi-environment deployments of AWS CDK apps #6361

Open
eladb opened this issue Apr 28, 2024 · 5 comments
Open

Multi-environment deployments of AWS CDK apps #6361

eladb opened this issue Apr 28, 2024 · 5 comments
Labels
✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl

Comments

@eladb
Copy link
Contributor

eladb commented Apr 28, 2024

Use Case

I am building a custom AWS CDK platform provider and would like to roll out my application across multiple AWS environments (accounts/regions).

Proposed Solution

I think an interesting approach to consider is to automatically create a copy of the application construct tree for each target environment (same way we are doing for testing).

Implementation Notes

No response

Component

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
  • If this issue is labeled needs-discussion, it means the spec has not been finalized yet. Please reach out on the #dev channel in the Wing Slack.
@eladb eladb added ✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl labels Apr 28, 2024
@garysassano
Copy link
Collaborator

How are you going to source the credentials for the different AWS accounts?

@eladb
Copy link
Contributor Author

eladb commented Apr 28, 2024

This is handled by the AWS CDK CLI. It already has support for multiple deployment environments (with cross account roles and all the shebang).

@garysassano
Copy link
Collaborator

garysassano commented Apr 28, 2024

The CDK CLI supports multi-account deployments, but it requires some setup. You need to bootstrap a primary "master" account first. Then, you bootstrap additional "slave" accounts, including a trust policy that allows the master account to deploy to them.

To enable this workflow in Wing, we could probably add support for specifying the target AWS account IDs and regions in the wing.toml config file.

Alternatively, we could use different AWS profiles for each environment. With this approach, the user would still need to bootstrap each environment individually and specify the name of each profile in the wing.toml, but you would be able to skip the chain of trust between the CDK bootstrap stacks.

@eladb
Copy link
Contributor Author

eladb commented Apr 29, 2024

As I see it, deployment is currently the responsibility of the target provisioning engine and not the Wing CLI. This comes with with some constraints and limitations but also allows users to leverage existing downstream tools and workflows for deployment and orchestration.

To that end, we should make sure it's possible to model these multi-environment systems in Wing (with some degrees of freedom but not all), and let the AWS CDK handle the rest.

@hasanaburayyan
Copy link
Collaborator

hasanaburayyan commented May 21, 2024

One workaround we found was to use a custom platform and create multiple stacks per env, and passing in configs per environment something like this in the app constructor:

Ive ommitted what the configs look like, just to show the idea here

super(cdkApp, props.rootId ?? "Default", props);
// ...
const Root = props.rootConstruct;
for (const [name, env] of Object.entries(config.environments ?? {})) {
      const stack = new MyStack(this, `wing-${name}`, {
        config: config,
        environment: env,
      });
      new Root(stack, name);
    }

We probably want to find some way to implement this multiple env support in the awscdk platform itself so custom platforms are not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl
Projects
Status: 🤝 Backlog - handoff to owners
Development

No branches or pull requests

3 participants