# TagMutability

The tag mutability setting for your repository.

- Source: [`aws-ecr/lib/repository.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-ecr/lib/repository.ts#L1155)
- Type last changed: v2.216.0 · 22 Sep 2025

## Example

TypeScript:

```ts
// Make all tags immutable except for those starting with 'dev-' or 'test-'
new ecr.Repository(this, 'Repo', {
  imageTagMutability: ecr.TagMutability.IMMUTABLE_WITH_EXCLUSION,
  imageTagMutabilityExclusionFilters: [
    ecr.ImageTagMutabilityExclusionFilter.wildcard('dev-*'),
    ecr.ImageTagMutabilityExclusionFilter.wildcard('test-*'),
  ],
});
```

Python:

```python
# Make all tags immutable except for those starting with 'dev-' or 'test-'
ecr.Repository(self, "Repo",
    image_tag_mutability=ecr.TagMutability.IMMUTABLE_WITH_EXCLUSION,
    image_tag_mutability_exclusion_filters=[
        ecr.ImageTagMutabilityExclusionFilter.wildcard("dev-*"),
        ecr.ImageTagMutabilityExclusionFilter.wildcard("test-*")
    ]
)
```

Java:

```java
// Make all tags immutable except for those starting with 'dev-' or 'test-'
// Make all tags immutable except for those starting with 'dev-' or 'test-'
Repository.Builder.create(this, "Repo")
        .imageTagMutability(TagMutability.IMMUTABLE_WITH_EXCLUSION)
        .imageTagMutabilityExclusionFilters(List.of(ImageTagMutabilityExclusionFilter.wildcard("dev-*"), ImageTagMutabilityExclusionFilter.wildcard("test-*")))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// Make all tags immutable except for those starting with 'dev-' or 'test-'
// Make all tags immutable except for those starting with 'dev-' or 'test-'
new Repository(this, "Repo", new RepositoryProps {
    ImageTagMutability = TagMutability.IMMUTABLE_WITH_EXCLUSION,
    ImageTagMutabilityExclusionFilters = new [] { ImageTagMutabilityExclusionFilter.Wildcard("dev-*"), ImageTagMutabilityExclusionFilter.Wildcard("test-*") }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Make all tags immutable except for those starting with 'dev-' or 'test-'
// Make all tags immutable except for those starting with 'dev-' or 'test-'
ecr.NewRepository(this, jsii.String("Repo"), &RepositoryProps{
	ImageTagMutability: ecr.TagMutability_IMMUTABLE_WITH_EXCLUSION,
	ImageTagMutabilityExclusionFilters: []ImageTagMutabilityExclusionFilter{
		ecr.ImageTagMutabilityExclusionFilter_Wildcard(jsii.String("dev-*")),
		ecr.ImageTagMutabilityExclusionFilter_*Wildcard(jsii.String("test-*")),
	},
})
```

## Members

| Member | Description |
| --- | --- |
| `MUTABLE` | allow image tags to be overwritten. |
| `IMMUTABLE` | all image tags within the repository will be immutable which will prevent them from being overwritten. |
| `IMMUTABLE_WITH_EXCLUSION` | all image tags within the repository will be immutable, while allowing you to define some filters for tags that can be changed. |
| `MUTABLE_WITH_EXCLUSION` | allow image tags to be overwritten while allowing you to define some filters for tags that should remain unchanged. |

## Referenced by

- [`RepositoryProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecr.RepositoryProps.html).imageTagMutability
