π§ AWS EC2 Auto Scaling Group Launch Template is not configured to require IMDSv2 - prod.logic.yaml π’
- Contextual name: π§ prod.logic.yaml π’
- ID:
/ce/ca/aws/autoscaling/group-launch-template-imdsv2/prod.logic.yaml
- Located in: π AWS EC2 Auto Scaling Group Launch Template is not configured to require IMDSv2 π’
Flagsβ
- π’ Logic test success
- π’ Logic with extracts
- π’ Logic with test data
Input Typeβ
Type | API Name | Extracts | Extract Files | Logic Files | |
---|---|---|---|---|---|
π | π AWS EC2 Auto Scaling Group | CA10__CaAwsAutoScalingGroup__c | 6 | 1 | 5 |
Usesβ
- π AWS EC2 Auto Scaling Group - object.extracts.yaml
- π AWS EC2 Launch Template Version - object.extracts.yaml
- π§ͺ test-data.json
Test Results π’β
Generated at: 2025-06-25T13:41:05.728456259Z Open
Result | Id | Condition Index | Condition Text | Runtime Error |
---|---|---|---|---|
π’ | test1 | βοΈ 99 | βοΈ isDisappeared(CA10__disappearanceTime__c) | βοΈ null |
π’ | test2 | βοΈ 199 | βοΈ extract('CA10__launchConfigurationName__c').isNotEmpty() | βοΈ null |
π’ | test3 | βοΈ 299 | βοΈ extract('CA10A1__launchTemplateId__c').isNotEmpty() && (isEmptyLookup('CA10A1__launchTemplate__r') || isEmptyLookup('CA10A1__launchTemplate__r.CA10A1__latestVersion__r')) | βοΈ null |
π’ | test4 | βοΈ 299 | βοΈ extract('CA10A1__launchTemplateId__c').isNotEmpty() && (isEmptyLookup('CA10A1__launchTemplate__r') || isEmptyLookup('CA10A1__launchTemplate__r.CA10A1__latestVersion__r')) | βοΈ null |
π’ | test5 | βοΈ 399 | βοΈ extract('CA10A1__mixedInstancesLaunchTemplateId__c').isNotEmpty() && (isEmptyLookup('CA10A1__mixedInstancesLaunchTemplate__r') || isEmptyLookup('CA10A1__mixedInstancesLaunchTemplate__r.CA10A1__latestVersion__r')) | βοΈ null |
π’ | test6 | βοΈ 399 | βοΈ extract('CA10A1__mixedInstancesLaunchTemplateId__c').isNotEmpty() && (isEmptyLookup('CA10A1__mixedInstancesLaunchTemplate__r') || isEmptyLookup('CA10A1__mixedInstancesLaunchTemplate__r.CA10A1__latestVersion__r')) | βοΈ null |
π’ | test7 | βοΈ 499 | βοΈ extract('CA10A1__launchTemplateId__c').isNotEmpty() && extract('CA10A1__launchTemplate__r.CA10A1__latestVersion__r.CA10A1__metadataHttpEndpoint__c') == 'disabled' | βοΈ null |
π’ | test8 | βοΈ 599 | βοΈ extract('CA10A1__mixedInstancesLaunchTemplateId__c').isNotEmpty() && extract('CA10A1__mixedInstancesLaunchTemplate__r.CA10A1__latestVersion__r.CA10A1__metadataHttpEndpoint__c') == 'disabled' | βοΈ null |
π’ | test9 | βοΈ 699 | βοΈ extract('CA10A1__launchTemplateId__c').isNotEmpty() && extract('CA10A1__launchTemplate__r.CA10A1__latestVersion__r.CA10A1__metadataHttpTokens__c') == 'required' | βοΈ null |
π’ | test10 | βοΈ 799 | βοΈ extract('CA10A1__mixedInstancesLaunchTemplateId__c').isNotEmpty() && extract('CA10A1__mixedInstancesLaunchTemplate__r.CA10A1__latestVersion__r.CA10A1__metadataHttpTokens__c') == 'required' | βοΈ null |
π’ | test11 | βοΈ 800 | βοΈ otherwise | βοΈ null |
π’ | test12 | βοΈ 800 | βοΈ otherwise | βοΈ null |
Generationβ
File | MD5 | |
---|---|---|
Open | /ce/ca/aws/autoscaling/group-launch-template-imdsv2/policy.yaml | 2BA738690B9315E9C7CB7C6FC7A0EDC5 |
Open | /ce/ca/aws/autoscaling/group-launch-template-imdsv2/prod.logic.yaml | E373BD538ED2D1CA829149C90F27BC79 |
Open | /ce/ca/aws/autoscaling/group-launch-template-imdsv2/test-data.json | 30BAABD8C965221D8C82CE87D97F01E4 |
Open | /types/CA10__CaAwsAutoScalingGroup__c/object.extracts.yaml | 134069A12987447E64F62153975AC9A7 |
Open | /types/CA10A1__CaAwsEc2LaunchTemplateVersion__c/object.extracts.yaml | 0CF0050EB6BA851041A4284E9AEA6611 |
Generate FULL scriptβ
java -jar repo-manager.jar policies generate FULL /ce/ca/aws/autoscaling/group-launch-template-imdsv2/prod.logic.yaml
Generate DEBUG scriptβ
java -jar repo-manager.jar policies generate DEBUG /ce/ca/aws/autoscaling/group-launch-template-imdsv2/prod.logic.yaml
Generate CAPTURE_TEST_DATA scriptβ
java -jar repo-manager.jar policies generate CAPTURE_TEST_DATA /ce/ca/aws/autoscaling/group-launch-template-imdsv2/prod.logic.yaml
Generate TESTS scriptβ
java -jar repo-manager.jar policies generate TESTS /ce/ca/aws/autoscaling/group-launch-template-imdsv2/prod.logic.yaml
Execute testsβ
java -jar repo-manager.jar policies test /ce/ca/aws/autoscaling/group-launch-template-imdsv2/prod.logic.yaml
Contentβ
---
inputType: "CA10__CaAwsAutoScalingGroup__c"
importExtracts:
- file: "/types/CA10A1__CaAwsEc2LaunchTemplateVersion__c/object.extracts.yaml"
- file: "/types/CA10__CaAwsAutoScalingGroup__c/object.extracts.yaml"
testData:
- file: "test-data.json"
conditions:
- status: "INAPPLICABLE"
currentStateMessage: "The Auto Scaling group uses a launch configuration."
remediationMessage: "Consider migrating the Auto Scaling group to launch template."
check:
NOT_EMPTY:
arg:
EXTRACT: "CA10__launchConfigurationName__c"
- status: "UNDETERMINED"
currentStateMessage: "The launch template is not present in the CMDB."
check:
AND:
args:
- NOT_EMPTY:
arg:
EXTRACT: "CA10A1__launchTemplateId__c"
- OR:
args:
- IS_EMPTY_LOOKUP: "CA10A1__launchTemplate__r"
- IS_EMPTY_LOOKUP: "CA10A1__launchTemplate__r.CA10A1__latestVersion__r"
- status: "UNDETERMINED"
currentStateMessage: "The launch template is not present in the CMDB."
check:
AND:
args:
- NOT_EMPTY:
arg:
EXTRACT: "CA10A1__mixedInstancesLaunchTemplateId__c"
- OR:
args:
- IS_EMPTY_LOOKUP: "CA10A1__mixedInstancesLaunchTemplate__r"
- IS_EMPTY_LOOKUP: "CA10A1__mixedInstancesLaunchTemplate__r.CA10A1__latestVersion__r"
- status: "INCOMPLIANT"
currentStateMessage: "Access to the HTTP endpoint of the instance metadata service is disabled."
remediationMessage: "Consider enabling access to the instance metadata."
check:
AND:
args:
- NOT_EMPTY:
arg:
EXTRACT: "CA10A1__launchTemplateId__c"
- IS_EQUAL:
left:
EXTRACT: "CA10A1__launchTemplate__r.CA10A1__latestVersion__r.CA10A1__metadataHttpEndpoint__c"
right:
TEXT: "disabled"
- status: "INCOMPLIANT"
currentStateMessage: "Access to the HTTP endpoint of the instance metadata service is disabled."
remediationMessage: "Consider enabling access to the instance metadata."
check:
AND:
args:
- NOT_EMPTY:
arg:
EXTRACT: "CA10A1__mixedInstancesLaunchTemplateId__c"
- IS_EQUAL:
left:
EXTRACT: "CA10A1__mixedInstancesLaunchTemplate__r.CA10A1__latestVersion__r.CA10A1__metadataHttpEndpoint__c"
right:
TEXT: "disabled"
- status: "COMPLIANT"
currentStateMessage: "The launch template settings require IMDSv2."
check:
AND:
args:
- NOT_EMPTY:
arg:
EXTRACT: "CA10A1__launchTemplateId__c"
- IS_EQUAL:
left:
EXTRACT: "CA10A1__launchTemplate__r.CA10A1__latestVersion__r.CA10A1__metadataHttpTokens__c"
right:
TEXT: "required"
- status: "COMPLIANT"
currentStateMessage: "The launch template settings require IMDSv2."
check:
AND:
args:
- NOT_EMPTY:
arg:
EXTRACT: "CA10A1__mixedInstancesLaunchTemplateId__c"
- IS_EQUAL:
left:
EXTRACT: "CA10A1__mixedInstancesLaunchTemplate__r.CA10A1__latestVersion__r.CA10A1__metadataHttpTokens__c"
right:
TEXT: "required"
otherwise:
status: "INCOMPLIANT"
currentStateMessage: "IMDSv2 is not required when requesting instance metadata."
remediationMessage: "Configure the template to only allow IMDSv2 calls."