AMIs must not be broadly shared. Granting multiple AWS accounts or group-based access increases the attack surface and can expose embedded credentials, custom configurations, or vulnerable images to unintended parties.
For Ansible tasks using the amazon.aws.ec2_ami or ec2_ami modules, launch_permissions should be restricted to at most one explicit AWS account and must not include group_names. This rule flags tasks where launch_permissions.group_names is present or where launch_permissions.user_ids contains more than one entry.
Secure example with a single allowed account:
- name:Register AMI with restricted launch permissionsamazon.aws.ec2_ami:name:my-amiimage_id:ami-0123456789abcdef0launch_permissions:user_ids:- "123456789012"
Compliant Code Examples
- name:Allow AMI to be launched by another account V2amazon.aws.ec2_ami:name:my-amiimage_id:'{{ instance.image_id }}'state:presentlaunch_permissions:user_ids:['123456789012']
Non-Compliant Code Examples
- name:Update AMI Launch Permissions, making it publicamazon.aws.ec2_ami:name:my-amiimage_id:"{{ instance.image_id }}"state:presentlaunch_permissions:group_names:['all']- name:Allow AMI to be launched by another accountamazon.aws.ec2_ami:name:my-amiimage_id:"{{ instance.image_id }}"state:presentlaunch_permissions:user_ids:['123456789012','121212']
1
2
rulesets:- Ansible / AWS # Rules to enforce / AWS.
맞춤형 데모 요청
Datadog 시작하기
Ask AI
AI-generated responses may be inaccurate. Verify important info.