Best practice for cross account S3 bucket access

0

We are trying to turn on access log for a load balancer following this page https://docs.aws.amazon.com/elasticloadbalancing/latest/application/enable-access-logging.html, the problem here is that the load balancer and S3 bucket are in different AWS accounts. Would like to know the best practice to achieve this, should we turn on ACL in the S3 bucket or there are some preferred ways, thank you!

已提問 1 年前檢視次數 1162 次
2 個答案
0

Hi, You can use policies to manage cross account access. You might find this document useful - https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-walkthroughs-managing-access-example2.html

profile picture
Syd
已回答 1 年前
0

AWS started to say in their documentation, try not to use ACL's Granting access to the S3 log delivery group using your bucket ACL is not recommended. Here is an example Bucket policy I use to allow cross Account Access.. Replace [bucketname] with the bucket name this policy is being applied too and replace the account number 111111111111 with the account(s) that need to write their logs from to this bucket.

Note, the AWS Account 652711504416 is for EU-west-2. Reference can be seen here depending on which region your ELB Logs are being delievered from so may need updating. https://docs.aws.amazon.com/elasticloadbalancing/latest/application/enable-access-logging.html

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "ELBRegionEu-West-2",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::652711504416:root"
            },
            "Action": "s3:PutObject",
            "Resource": "arn:aws:s3:::[bucketname]/*"
        },
        {
            "Sid": "AWSLogdeliveryWriteELB",
            "Effect": "Allow",
            "Principal": {
                "Service": "logdelivery.elasticloadbalancing.amazonaws.com"
            },
            "Action": "s3:PutObject",
            "Resource": "arn:aws:s3:::[bucketname]/*",
	    "Condition": {
			"StringEquals": {
                        "aws:SourceAccount": [
                        "111111111111"
                    ]
                }
	}
        },
        {
            "Sid": "AWSLogDeliveryWrite",
            "Effect": "Allow",
            "Principal": {
            "Service": "delivery.logs.amazonaws.com"
            },
            "Action": "s3:PutObject",
            "Resource": "arn:aws:s3:::[bucketname]/*",
            "Condition": {
                "StringEquals": {
				"aws:SourceAccount": [
                        "111111111111"
                    ],
                    "s3:x-amz-acl": "bucket-owner-full-control"
                }
            }
        },
        {
            "Sid": "AWSLogDeliveryAclCheck",
            "Effect": "Allow",
            "Principal": {
            "Service": "delivery.logs.amazonaws.com"
            },
            "Action": "s3:GetBucketAcl",
            "Resource": "arn:aws:s3:::[bucketname]",
	    "Condition": {
			"StringEquals": {
                    "aws:SourceAccount": [
                        "111111111111"
                    ]
                }
	}
        },
        {
            "Sid": "DenyInsecureTransport",
            "Effect": "Deny",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::[bucketname]/*",
                "arn:aws:s3:::[bucketname]"
            ],
            "Condition": {
                "Bool": {
                    "aws:SecureTransport": "false"
                }
            }
        }
    ]
}
profile picture
專家
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南