I am trying to create an IAM policy that allows some actions on a resource, but only if the access key is used from a specific Elastic Beanstalk application or container. Does anyone know how to do this? I tried this, but to no avail:
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::example-bucket/*",
"Condition": {
"ArnEquals": {
"aws:SourceArn": "arn:aws:elasticbeanstalk:..."
}
}
Restricting by ip instead works, but Elastic Beanstalk environments frequently change the ips of the servers that they create, so this is not a viable option:
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::example-bucket/*",
"Condition": {
"IpAddress": {
"aws:SourceIp": "..."
}
}