Guided Walkthroughs

Configuration Packages

By Implementation

Service Control PoliciesConfig RulesAuto Remediation RulesConformance PacksAmazon GuardDutyAmazon InspectorAWS Security HubAWS Network FirewallRoute53 Resolver SecurityAmazon MacieS3 Bucket PoliciesCloudWatch Alarms and Event RulesAWS WAFAWS Secrets ManagerAWS Systems ManagerSecurity Groups & NACLsAWS KMSAWS SSOIAM PoliciesVPC Endpoint PoliciesCloudFormation Guard RulesLoad BalancersRDS Event SubscriptionsAWS Resource Access Manager (RAM)

By Service Protected

Reference Guides

Other

CloudFormation Guard Rules

Cloudformation Guard Rules for Amazon ECR

CloudFormation guard rules template for Amazon ECR resources

The following rules are included: 

  • Image Scan on Push Enabled
  • Resource Policy Configured
  • KMS Encryption Enabled
  • Lifecycle Policy Configured
CloudFormation Validation Tool: Syntax and Security validation for your templates online

let ecr_repositories = Resources.*[
	Type == "AWS::ECR::Repository"
]

rule ecr_vuln_scan when %ecr_repositories !empty {
	%ecr_repositories {
		Properties {
			ImageScanningConfiguration exists <<ImageScanningConfiguration is not configured (i.e. disabled).>>
			when ImageScanningConfiguration exists {
				ImageScanningConfiguration {
					ScanOnPush == true <<Image scan on push is disabled.>>
				}
			}
		}
	}
}

rule ecr_resource_policy when %ecr_repositories !empty {
	%ecr_repositories {
		Properties {
			RepositoryPolicyText exists <<Resource policy is not configured.>>
		}
	}
}

rule ecr_kms_encryption_enabled when %ecr_repositories !empty {
	%ecr_repositories {
		Properties {
			EncryptionConfiguration exists <<EncryptionConfiguration is not configured (Default is AES256).>>
			when EncryptionConfiguration exists {
				EncryptionConfiguration {
					EncryptionType == "KMS" <<KMS encryption is not enabled.>>
				}
			}
		}
	}
}

rule ecr_repository_lifecycle_policies when %ecr_repositories !empty {
	%ecr_repositories {
		Properties {
			LifecyclePolicy exists <<Lifecycle policy is not configured.>>
		}
	}
}



Actions



Customize Template

* Required field

Upgrade to Premium for More Features
Sign up

Guided Walkthroughs
Step-by-step configuration wizards for your environment
Dedicated Security Account
AWS Backup Strategy
VPC Connectivity Setup
Automated Patching
All Guides
Configuration Packages
Pre-built packages for common configuration
Common SCPs
CloudFormation Guard Rules
Auto Remediation Rules
IAM Monitoring & Compliance
All Packages
Automated Assessments
  • 350+ security checks
  • Well-architected reviews
  • Detailed compliance reports
  • Remediation templates
  • Email summaries
  • Learn more