Skip to main content

🧠 AWS EC2 Instance with an auto-assigned public IP address is in a default subnet - prod.logic.yaml 🟒

Flags​

Input Type​

TypeAPI NameExtractsExtract FilesLogic Files
πŸ”’πŸ“— AWS EC2 InstanceCA10__CaAwsInstance__c12254

Uses​

Test Results πŸŸ’β€‹

Generated at: 2025-08-29T17:46:06.286584589Z Open

ResultIdCondition IndexCondition TextRuntime Error
🟒test1βœ”οΈ 99βœ”οΈ isDisappeared(CA10__disappearanceTime__c)βœ”οΈ null
🟒test2βœ”οΈ 199βœ”οΈ extract('CA10__publicIpAddress__c').isEmpty()βœ”οΈ null
🟒test4βœ”οΈ 299βœ”οΈ CA10__AWS_EC2_Elastic_IPs__r.has(COMPLIANT)βœ”οΈ null
🟒test5βœ”οΈ 499βœ”οΈ CA10__vpcSubnet__r.CA10__defaultForAz__c == falseβœ”οΈ null
🟒test6βœ”οΈ 599βœ”οΈ CA10__vpcSubnet__r.CA10__mapPublicIpOnLaunch__c == trueβœ”οΈ null
🟒test7βœ”οΈ 399βœ”οΈ isEmptyLookup('CA10__vpcSubnet__r')βœ”οΈ null
🟒test8βœ”οΈ 600βœ”οΈ otherwiseβœ”οΈ null

Generation​

FileMD5
Open/ce/ca/aws/ec2/instance-with-public-ip-in-default-subnet/policy.yaml55A7FBF38BD08F2A3F87A5D9FB791FC4
Open/ce/ca/aws/ec2/instance-with-public-ip-in-default-subnet/prod.logic.yamlF8BD05FF9F92E6EE445E68BFE6764416
Open/types/CA10__CaAwsSubnet__c/object.extracts.yaml7F012284F2BF194EA79A157883554CA2
Open/types/CA10__CaAwsInstance__c/object.extracts.yaml802FA80DBDE640AF85A69B42E51E0CCD
Open/ce/ca/aws/ec2/instance-with-public-ip-in-default-subnet/test-data.json4A4616F804418A47DA4350988B0C4DB5

Generate FULL script​

java -jar repo-manager.jar policies generate FULL /ce/ca/aws/ec2/instance-with-public-ip-in-default-subnet/prod.logic.yaml

Generate DEBUG script​

java -jar repo-manager.jar policies generate DEBUG /ce/ca/aws/ec2/instance-with-public-ip-in-default-subnet/prod.logic.yaml

Generate CAPTURE_TEST_DATA script​

java -jar repo-manager.jar policies generate CAPTURE_TEST_DATA /ce/ca/aws/ec2/instance-with-public-ip-in-default-subnet/prod.logic.yaml

Generate TESTS script​

java -jar repo-manager.jar policies generate TESTS /ce/ca/aws/ec2/instance-with-public-ip-in-default-subnet/prod.logic.yaml

Execute tests​

java -jar repo-manager.jar policies test /ce/ca/aws/ec2/instance-with-public-ip-in-default-subnet/prod.logic.yaml

Content​

Open File

inputType: "CA10__CaAwsInstance__c"
importExtracts:
- file: /types/CA10__CaAwsInstance__c/object.extracts.yaml
- file: /types/CA10__CaAwsSubnet__c/object.extracts.yaml
testData:
- file: "test-data.json"
conditions:
- status: "COMPLIANT"
currentStateMessage: "The instance does not have a public IP address."
check:
IS_EMPTY:
arg:
EXTRACT: "CA10__publicIpAddress__c"
- status: "COMPLIANT"
currentStateMessage: "The instance has an Elastic IP address."
check:
RELATED_LIST_HAS:
status: "COMPLIANT"
relationshipName: "CA10__AWS_EC2_Elastic_IPs__r"
- status: "UNDETERMINED"
currentStateMessage: "Cannot determine if the instance is in a default subnet because subnet information is missing."
check:
IS_EMPTY_LOOKUP: "CA10__vpcSubnet__r"
- status: "COMPLIANT"
currentStateMessage: "Instance has a public IP address and is located in a custom subnet."
check:
IS_EQUAL:
left:
FIELD:
path: "CA10__vpcSubnet__r.CA10__defaultForAz__c"
right:
BOOLEAN: false
- status: "INCOMPLIANT"
currentStateMessage: "The instance has an auto-assigned public IP address and is located in a default subnet."
remediationMessage: "Consider moving the instance to a custom subnet intended\
\ for public resources or removing its public IP address if internet access is not required."
check:
IS_EQUAL:
left:
FIELD:
path: "CA10__vpcSubnet__r.CA10__mapPublicIpOnLaunch__c"
right:
BOOLEAN: true
otherwise:
status: "COMPLIANT"
currentStateMessage: "The instance has an auto-assigned public IP address but\
\ the Auto-assign Public IPv4 Address subnet attribute is disabled."
relatedLists:
- relationshipName: "CA10__AWS_EC2_Elastic_IPs__r"
conditions: []
otherwise:
status: "COMPLIANT"
currentStateMessage: "This is an Elastic IP address."