Skip to content

Instantly share code, notes, and snippets.

@spasam
Created March 27, 2023 18:51
Show Gist options
  • Select an option

  • Save spasam/f1b0810c54c2bf32531a5a7ef6e944c1 to your computer and use it in GitHub Desktop.

Select an option

Save spasam/f1b0810c54c2bf32531a5a7ef6e944c1 to your computer and use it in GitHub Desktop.
Prevent temporary credentials issued to EC2 instances from being used elsewhere
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:ec2InstanceSourceVPC": "${aws:SourceVpc}"
},
"Null": {
"ec2:SourceInstanceARN": "false"
},
"BoolIfExists": {
"aws:ViaAWSService": "false"
}
}
},
{
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:ec2InstanceSourcePrivateIPv4": "${aws:VpcSourceIp}"
},
"Null": {
"ec2:SourceInstanceARN": "false"
},
"BoolIfExists": {
"aws:ViaAWSService": "false"
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment