Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions pkg/project/provider/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,37 @@ var steps = []bootstrapStep{
func(ctx context.Context, cfg aws.Config, data *AwsBootstrapData) error {
return nil
},

// Step: apply ECR lifecycle policy to clean up untagged images
func(ctx context.Context, cfg aws.Config, data *AwsBootstrapData) error {
ecrClient := ecr.NewFromConfig(cfg)
repoName := "sst-asset"

lifecyclePolicy := `{
"rules": [
{
"rulePriority": 1,
"description": "Expire untagged images pushed over 30 days ago",
"selection": {
"tagStatus": "untagged",
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": 30
},
"action": {"type": "expire"}
}
]
}`

_, err := ecrClient.PutLifecyclePolicy(ctx, &ecr.PutLifecyclePolicyInput{
RepositoryName: aws.String(repoName),
LifecyclePolicyText: aws.String(lifecyclePolicy),
})
if err != nil {
slog.Warn("failed to set ECR lifecycle policy", "error", err)
}
return nil
},
}

type AwsHome struct {
Expand Down