I am trying to deny uploads from an ec2 instance (while SSH in it) to an s3 bucket using policy bucket. My ec2 uploads a file from the CLI with the following command: "aws s3 cp text.txt s3://bucket-name". The bucket policy in place is the following in json:
{
"Version": "2012-10-17",
"Id": "Policy1668560706336",
"Statement": [
{
"Sid": "Stmt1668560704089",
"Effect": "Deny",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::bucket-name/*"
}
]
}
any ideas why this wouldn't work to deny my ec2 instance from uploading to the s3 bucket? (bucket and ec2 instance are in the same region of the same account).
Thanks in advance.
I was expecting the bucket policy to deny the upload from the ec2 instance.