# DeletionProtectionCheck

The deletion protection check options.

- Source: [`aws-appconfig/lib/util.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-appconfig/lib/util.ts#L4)
- Type last changed: v2.176.0 · 15 Jan 2025

## Example

TypeScript:

```ts
declare const application: appconfig.Application;
declare const alarm: cloudwatch.Alarm;
declare const compositeAlarm: cloudwatch.CompositeAlarm;
declare const bucket: s3.Bucket;

// Environment deletion protection check
new appconfig.Environment(this, 'MyEnvironment', {
  application,
  deletionProtectionCheck: appconfig.DeletionProtectionCheck.APPLY,
});

// configuration profile with deletion protection check
new appconfig.HostedConfiguration(this, 'MyHostedConfigFromFile', {
  application,
  content: appconfig.ConfigurationContent.fromFile('config.json'),
  deletionProtectionCheck: appconfig.DeletionProtectionCheck.BYPASS,
});

new appconfig.SourcedConfiguration(this, 'MySourcedConfiguration', {
  application,
  location: appconfig.ConfigurationSource.fromBucket(bucket, 'path/to/file.json'),
  deletionProtectionCheck: appconfig.DeletionProtectionCheck.ACCOUNT_DEFAULT,
});
```

Python:

```python
# application: appconfig.Application
# alarm: cloudwatch.Alarm
# composite_alarm: cloudwatch.CompositeAlarm
# bucket: s3.Bucket

# Environment deletion protection check
appconfig.Environment(self, "MyEnvironment",
    application=application,
    deletion_protection_check=appconfig.DeletionProtectionCheck.APPLY
)

# configuration profile with deletion protection check
appconfig.HostedConfiguration(self, "MyHostedConfigFromFile",
    application=application,
    content=appconfig.ConfigurationContent.from_file("config.json"),
    deletion_protection_check=appconfig.DeletionProtectionCheck.BYPASS
)

appconfig.SourcedConfiguration(self, "MySourcedConfiguration",
    application=application,
    location=appconfig.ConfigurationSource.from_bucket(bucket, "path/to/file.json"),
    deletion_protection_check=appconfig.DeletionProtectionCheck.ACCOUNT_DEFAULT
)
```

Java:

```java
Application application;
Alarm alarm;
CompositeAlarm compositeAlarm;
Bucket bucket;

// Environment deletion protection check
// Environment deletion protection check
Environment.Builder.create(this, "MyEnvironment")
        .application(application)
        .deletionProtectionCheck(DeletionProtectionCheck.APPLY)
        .build();

// configuration profile with deletion protection check
// configuration profile with deletion protection check
HostedConfiguration.Builder.create(this, "MyHostedConfigFromFile")
        .application(application)
        .content(ConfigurationContent.fromFile("config.json"))
        .deletionProtectionCheck(DeletionProtectionCheck.BYPASS)
        .build();

SourcedConfiguration.Builder.create(this, "MySourcedConfiguration")
        .application(application)
        .location(ConfigurationSource.fromBucket(bucket, "path/to/file.json"))
        .deletionProtectionCheck(DeletionProtectionCheck.ACCOUNT_DEFAULT)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Application application;
Alarm alarm;
CompositeAlarm compositeAlarm;
Bucket bucket;

// Environment deletion protection check
// Environment deletion protection check
new Environment(this, "MyEnvironment", new EnvironmentProps {
    Application = application,
    DeletionProtectionCheck = DeletionProtectionCheck.APPLY
});

// configuration profile with deletion protection check
// configuration profile with deletion protection check
new HostedConfiguration(this, "MyHostedConfigFromFile", new HostedConfigurationProps {
    Application = application,
    Content = ConfigurationContent.FromFile("config.json"),
    DeletionProtectionCheck = DeletionProtectionCheck.BYPASS
});

new SourcedConfiguration(this, "MySourcedConfiguration", new SourcedConfigurationProps {
    Application = application,
    Location = ConfigurationSource.FromBucket(bucket, "path/to/file.json"),
    DeletionProtectionCheck = DeletionProtectionCheck.ACCOUNT_DEFAULT
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var application Application
var alarm Alarm
var compositeAlarm CompositeAlarm
var bucket Bucket

// Environment deletion protection check
// Environment deletion protection check
appconfig.NewEnvironment(this, jsii.String("MyEnvironment"), &EnvironmentProps{
	Application: Application,
	DeletionProtectionCheck: appconfig.DeletionProtectionCheck_APPLY,
})

// configuration profile with deletion protection check
// configuration profile with deletion protection check
appconfig.NewHostedConfiguration(this, jsii.String("MyHostedConfigFromFile"), &HostedConfigurationProps{
	Application: Application,
	Content: appconfig.ConfigurationContent_FromFile(jsii.String("config.json")),
	DeletionProtectionCheck: appconfig.DeletionProtectionCheck_BYPASS,
})

appconfig.NewSourcedConfiguration(this, jsii.String("MySourcedConfiguration"), &SourcedConfigurationProps{
	Application: Application,
	Location: appconfig.ConfigurationSource_FromBucket(bucket, jsii.String("path/to/file.json")),
	DeletionProtectionCheck: appconfig.DeletionProtectionCheck_ACCOUNT_DEFAULT,
})
```

## Members

| Member | Description |
| --- | --- |
| `ACCOUNT_DEFAULT` | The default setting, which uses account-level deletion protection. |
| `APPLY` | Instructs the deletion protection check to run, even if deletion protection is disabled at the account level. |
| `BYPASS` | Instructs AWS AppConfig to bypass the deletion protection check and delete an environment or a configuration profile even if deletion protection would have otherwise prevented it. |

## Referenced by

- [`ConfigurationOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appconfig.ConfigurationOptions.html).deletionProtectionCheck
- [`EnvironmentOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appconfig.EnvironmentOptions.html).deletionProtectionCheck
- [`HostedConfiguration`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appconfig.HostedConfiguration.html).deletionProtectionCheck
- [`SourcedConfiguration`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appconfig.SourcedConfiguration.html).deletionProtectionCheck
