-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CloudFormation returned status code: Forbidden #39
Comments
It might be because my Lambda was within VPC, but the SecuirtyGroup Ingress and Egress was 0.0.0.0/0 so would that matter? |
If you're getting forbidden, I don't think It'd be the Security Group:
Seems like you have the ability to hit Did you get this solved? |
@mdalvi Did you ever figure out what causes this? |
My issue was that I am deploying a Custom Resource into a VPC with an S3 VPC Endpoint. And while creating the Endpoint, I followed instructions here (https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints-s3.html#bucket-policies-s3) and added a Deny for any S3 buckets that are not owned by my account Id. This then caused the custom resource to be blocked at the Endpoint. Unfortunately, I don't see any sane way to block s3 access outside of either my account OR the AWS account that owns the particular bucket that cloudformation uses. I haven't asked AWS if they'd hand over the account number, but I doubt they would. They do recommend unblocking the specific buckets, but they don't provide a way to do that at the endpoint policy (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-vpce-bucketnames.html), so the below is what I'm trying:
|
I had a similar issue with my Lambda backed custom resource (was in a VPC) and AWS support helped me to realise it's the changed S3 VPC endpoint policy that stopped my custom resource to report back on to the pre-signed S3 URL (see the ResponseURL field in the incoming event object). As soon as I relaxed that policy it started working again. Now I need to define that policy properly... |
If you figure out how to block access to external buckets but allow access to the Cloudformation buckets, please do share. |
This could be achieved with a specific IAM policy in the lambda. IAM with an explicit allow will block anything else. Such as: {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ListObjectsInBucket",
"Effect": "Allow",
"Action": ["s3:ListBucket"],
"Resource": ["arn:aws:s3:::bucket-name"]
},
{
"Sid": "AllObjectActions",
"Effect": "Allow",
"Action": "s3:*Object",
"Resource": ["arn:aws:s3:::bucket-name/*"]
}
]
}
|
When does cloud formation returns
Forbidden
status? This happened with me duringcreate
. I had a code where a the Lambda was supposed to upload file to S3 bucket and while that went successful the template got stuck!Here is what the log looks like
Its strange though never happened before, although one question, Am I suppose to randomize my
PhysicalResourceId
?, because right now its plain textThe text was updated successfully, but these errors were encountered: