Unverified Commit f5f94a21 authored by ysaito1001's avatar ysaito1001 Committed by GitHub
Browse files

Split CDK app between `smithy-rs` and `aws-sdk-rust` (#3514)

## Motivation and Context
A prerequisite for running canary in smithy-rs CI

## Description
This PR is essentially refactoring so that `canary-stack.ts` library can
be used by both `smithy-rs` and `aws-sdk-rust`. CDK apps are then split
into `bin/smithy-rs` and `bin/aws-sdk-rust`; the former is used by our
local development and the latter is used by our internal release
pipeline.

Merging this PR to the main branch will not affect anything. However, we
will need to update our internal release pipeline to use
`bin/aws-sdk-rust/*` instead when we release new SDKs:
- `npm run build` -> `npx tsc && npx cdk --app "node
build/bin/aws-sdk-rust/canary.js" synth`
- `npx cdk bootstrap` -> `npx cdk bootstrap --app "ts-node
--prefer-ts-exts bin/aws-sdk-rust/canary.ts"`
- `npx cdk --app "node build/bin/canary-only.js" synth` -> `npx cdk
--app "node build/bin/aws-sdk-rust/canary-only.js" synth`
- `npx cdk --app "node build/bin/canary-only.js" deploy --outputs-file
cdk-outputs.json` -> `npx cdk --app "node
build/bin/aws-sdk-rust/canary-only.js" deploy --outputs-file
cdk-outputs.json`

Also, when this PR is merged, we're ready to deploy a new canary stack
`smithy-rs-canary-stack` used by smithy-rs CI.

## Testing
> we will need to update our internal release pipeline to use
`bin/aws-sdk-rust/*` instead

Verified internally that it passed the release pipeline.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent 4fa38c40
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -13,8 +13,8 @@ on the `canary-runner` and `canary-lambda`. To do this, run the following:
```bash
npm install
npm run build
npx cdk --app "node build/bin/canary-only.js" synth
npx cdk --app "node build/bin/canary-only.js" deploy --outputs-file cdk-outputs.json
npx cdk --app "node build/bin/smithy-rs/canary-only.js" synth
npx cdk --app "node build/bin/smithy-rs/canary-only.js" deploy --outputs-file cdk-outputs.json
```

From there, you can just point the `canary-runner` to the `cdk-outputs.json` to run it:
+21 −0
Original line number Diff line number Diff line
#!/usr/bin/env node
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

// This CDK app sets up the absolute minimum set of resources to successfully
// execute the canary with. However, this one is used by our internal CI only.
// Use canary-only.ts in the sibling smithy-rs directory instead.

import "source-map-support/register";
import { App } from "aws-cdk-lib";
import { CanaryStack } from "../../lib/canary-stack";

const app = new App();
const env = { region: "us-west-2" };

new CanaryStack(app, "aws-sdk-rust-canary-stack", {
    lambdaExecutionRole: "aws-sdk-rust-canary-lambda-exec-role",
    env,
});
+34 −0
Original line number Diff line number Diff line
@@ -4,25 +4,31 @@
 * SPDX-License-Identifier: Apache-2.0
 */

// This CDK app, in addition to provisioning necessary resources for the canary,
// deploys a GihHub OIDC role to execute it from a CI in the `aws-sdk-rust` repository.

import "source-map-support/register";
import { App } from "aws-cdk-lib";
import { PullRequestCdnStack } from "../lib/smithy-rs/pull-request-cdn-stack";
import { CanaryStack } from "../lib/aws-sdk-rust/canary-stack";
import { OidcProviderStack } from "../lib/oidc-provider-stack";
import { CanaryStack, OidcProps } from "../../lib/canary-stack";
import { OidcProviderStack } from "../../lib/oidc-provider-stack";

const app = new App({});
const app = new App();
const env = { region: "us-west-2" };

const oidcProviderStack = new OidcProviderStack(app, "oidc-provider-stack", {
    env,
});

new PullRequestCdnStack(app, "smithy-rs-pull-request-cdn-stack", {
    githubActionsOidcProvider: oidcProviderStack.githubActionsOidcProvider,
    env,
});
const oidcProps: OidcProps = {
    roleId: "aws-sdk-rust",
    roleName: "aws-sdk-rust-canary",
    roleGithubOrg: "awslabs",
    roleGithubRepo: "aws-sdk-rust",
    provider: oidcProviderStack.githubActionsOidcProvider,
};

new CanaryStack(app, "aws-sdk-rust-canary-stack", {
    githubActionsOidcProvider: oidcProviderStack.githubActionsOidcProvider,
    lambdaExecutionRole: "aws-sdk-rust-canary-lambda-exec-role",
    oidcProps,
    env,
});
+6 −3
Original line number Diff line number Diff line
@@ -4,14 +4,17 @@
 * SPDX-License-Identifier: Apache-2.0
 */

// This CDK app sets up the absolute minimum set of resources to succesfully
// This CDK app sets up the absolute minimum set of resources to successfully
// execute the canary with.

import "source-map-support/register";
import { App } from "aws-cdk-lib";
import { CanaryStack } from "../lib/aws-sdk-rust/canary-stack";
import { CanaryStack } from "../../lib/canary-stack";

const app = new App();
const env = { region: "us-west-2" };

new CanaryStack(app, "aws-sdk-rust-canary-stack", { env });
new CanaryStack(app, "smithy-rs-canary-stack", {
    lambdaExecutionRole: "smithy-rs-canary-lambda-exec-role",
    env,
});
+43 −0
Original line number Diff line number Diff line
#!/usr/bin/env node
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

// This CDK app, in addition to provisioning necessary resources for CI checks
// and the canary, deploys a GihHub OIDC role to execute the canary from a CI
// in the `smithy-rs` repository.

import "source-map-support/register";
import { App } from "aws-cdk-lib";
import { PullRequestCdnStack } from "../../lib/smithy-rs/pull-request-cdn-stack";
import { CanaryStack, OidcProps } from "../../lib/canary-stack";
import { OidcProviderStack } from "../../lib/oidc-provider-stack";

const app = new App({});
const env = { region: "us-west-2" };

const oidcProviderStack = new OidcProviderStack(app, "oidc-provider-stack", {
    env,
});

const githubActionsOidcProvider = oidcProviderStack.githubActionsOidcProvider;

const oidcProps: OidcProps = {
    roleId: "smithy-rs",
    roleName: "smithy-rs-canary",
    roleGithubOrg: "smithy-lang",
    roleGithubRepo: "smithy-rs",
    provider: githubActionsOidcProvider,
};

new PullRequestCdnStack(app, "smithy-rs-pull-request-cdn-stack", {
    githubActionsOidcProvider: githubActionsOidcProvider,
    env,
});

new CanaryStack(app, "smithy-rs-canary-stack", {
    lambdaExecutionRole: "smithy-rs-canary-lambda-exec-role",
    oidcProps,
    env,
});
Loading