Skip to content

Commit

Permalink
Merge branch 'main' into mrgrain/feat/use-new-service-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain authored Jul 13, 2023
2 parents ad87209 + 3e9dfb2 commit f19ced0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/@aws-cdk/app-staging-synthesizer-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,22 @@ const app = new App({
});
```

### Auto Delete Staging Assets on Deletion

By default, the staging resources will be cleaned up on stack deletion. That means that the
S3 Bucket and ECR Repositories are set to `RemovalPolicy.DESTROY` and have `autoDeleteObjects`
or `autoDeleteImages` turned on. This creates custom resources under the hood to facilitate
cleanup. To turn this off, specify `autoDeleteStagingAssets: false`.

```ts
const app = new App({
defaultStackSynthesizer: AppStagingSynthesizer.defaultResources({
appId: 'my-app-id',
autoDeleteStagingAssets: false,
}),
});
```

## Using a Custom Staging Stack per Environment

If you want to customize some behavior that is not configurable via properties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,36 @@ describe(AppStagingSynthesizer, () => {
});
});

test('auto delete assets can be turned off', () => {
// GIVEN
app = new App({
defaultStackSynthesizer: AppStagingSynthesizer.defaultResources({
appId: APP_ID,
autoDeleteStagingAssets: false,
}),
});
stack = new Stack(app, 'Stack', {
env: {
account: '000000000000',
region: 'us-east-1',
},
});

const assetName = 'abcdef';
stack.synthesizer.addDockerImageAsset({
directoryName: '.',
sourceHash: 'abcdef',
assetName,
});

// WHEN
const asm = app.synth();

// THEN
Template.fromJSON(getStagingResourceStack(asm).template).resourceCountIs('Custom::ECRAutoDeleteImages', 0);
Template.fromJSON(getStagingResourceStack(asm).template).resourceCountIs('Custom::S3AutoDeleteObjects', 0);
});

describe('environment specifics', () => {
test('throws if App includes env-agnostic and specific env stacks', () => {
// GIVEN - App with Stack with specific environment
Expand Down

0 comments on commit f19ced0

Please sign in to comment.