Skip to content

Commit

Permalink
feat(appconfig): environment deletion protection (#32737)
Browse files Browse the repository at this point in the history
### Issue # (if applicable)

None

### Reason for this change

AWS AppConfig environment supports [deletion protection](https://docs.aws.amazon.com/appconfig/latest/userguide/deletion-protection.html) and this feature is not configurable from AWS CDK.

### Description of changes

- Add `DeletionProtectionCheck` enum
- Add `deletionProtectionCheck` prop to `EnvironmentOption`

There are two entities, `EnvironmentOptions` and `EnvironmentProps`, where `EnvironmentProps` is designed as an extension of `EnvironmentOptions` with the addition of an `application` prop.

```ts
export interface EnvironmentProps extends EnvironmentOptions {
  /**
   * The application to be associated with the environment.
   */
  readonly application: IApplication;
}

abstract class ApplicationBase extends cdk.Resource implements IApplication, IExtensible {
  public addEnvironment(id: string, options: EnvironmentOptions = {}): IEnvironment {
    return new Environment(this, id, {
      application: this,
      ...options,
    });
  }
```
Therefore, the current argument addition has also been made to `EnvironmentOptions`.

### Describe any new or updated permissions being added

None

### Description of how you validated changes

Add both unit and integ test.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
badmintoncryer authored Jan 9, 2025
1 parent b670ba8 commit 393e5c0
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 75 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
"ApplicationId": {
"Ref": "MyApplicationForEnv1F597ED9"
},
"DeletionProtectionCheck": "ACCOUNT_DEFAULT",
"Description": "This is the environment for integ testing",
"Monitors": [
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import { App, Duration, PhysicalName, Stack } from 'aws-cdk-lib';
import { Alarm, ComparisonOperator, CompositeAlarm, Metric, TreatMissingData } from 'aws-cdk-lib/aws-cloudwatch';
import { Role, ServicePrincipal, Effect, PolicyStatement, PolicyDocument } from 'aws-cdk-lib/aws-iam';
import { Application, ConfigurationContent, DeploymentStrategy, Environment, HostedConfiguration, Monitor, RolloutStrategy } from 'aws-cdk-lib/aws-appconfig';
import { Application, ConfigurationContent, DeletionProtectionCheck, DeploymentStrategy, Environment, HostedConfiguration, Monitor, RolloutStrategy } from 'aws-cdk-lib/aws-appconfig';

const app = new App();

Expand Down Expand Up @@ -54,6 +54,7 @@ const compositeAlarm = new CompositeAlarm(stack, 'MyCompositeAlarm', {
const env = new Environment(stack, 'MyEnvironment', {
application: appForEnv,
description: 'This is the environment for integ testing',
deletionProtectionCheck: DeletionProtectionCheck.ACCOUNT_DEFAULT,
monitors: [
Monitor.fromCloudWatchAlarm(alarm),
Monitor.fromCfnMonitorsProperty({
Expand Down
Loading

0 comments on commit 393e5c0

Please sign in to comment.