- Newest
- Most votes
- Most comments
You cannot use any conditions related with organization, because the service principal is not a member of your organization.
Just delete all conditions related to Account ID is a simple stupid solution. And keep S3 bucket name as secret. I believe that delivery.logs.amazonaws.com
service is safe enough.
{
"Sid":"AWSLogDeliveryWrite",
"Effect":"Allow",
"Principal":{
"Service":"delivery.logs.amazonaws.com"
},
"Action":"s3:PutObject",
"Resource":"my-s3-arn",
"Condition":{
"StringEquals":{
"s3:x-amz-acl":"bucket-owner-full-control"
}
}
}
I know it is not best, but simple! :)
Thanks for your answer @posquit0. That was my concern, that the delivery service principal is not member of my organization. There should be a way to restrict access to service principals within an organization as you cannot keep a bucket name as secret from a malicious ex employee.
F.Y.I. In Nov 13 2023 , aws:SourceOrgID and aws:SourceOrgPaths have been released. You can restrict specific organization accounts that are able to delivery flow logs to s3 bucket.
https://aws.amazon.com/about-aws/whats-new/2023/11/organization-wide-iam-condition-keys-restrict-aws-service-to-service-requests/?nc1=h_ls https://aws.amazon.com/jp/blogs/security/use-scalable-controls-for-aws-services-accessing-your-resources/
In Nov 2023 AWS announced AWS:SourceOrgID
condition that can be used to limit access to an org via service. You can secure your buckets again.
An example policy that works for us:
{
"Version": "2012-10-17",
"Id": "CrossAccountAccess",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "delivery.logs.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::bucket/*",
"Condition": {
"StringEquals": {
"AWS:SourceOrgID": "o-xxxx"
}
}
},
{
"Effect": "Allow",
"Principal": {
"Service": "delivery.logs.amazonaws.com"
},
"Action": "s3:GetBucketAcl",
"Resource": "arn:aws:s3:::bucket",
"Condition": {
"StringEquals": {
"AWS:SourceOrgID": "o-zzzz"
}
}
}
]
}
I am creating central S3 bucket to get all VPC flow logs from many accounts within my org.. I using the principal org ID as the condition, however ideally we'd prevent one account overwriting another account's data, how can i make more cahnges to the following policy to be able to follow principle of least privilege ?
S3BucketPolicy: Type: AWS::S3::BucketPolicy Properties: Bucket: !Ref S3Bucket PolicyDocument: Version: '2012-10-17' Statement:
Effect: Allow Principal: AWS: '*' Action:
- s3:ListBucket
- s3:PutObject
- s3:GetBucketAcl Resource:
- 'arn:aws:s3:::testpolicycfns3vpc'
- 'arn:aws:s3:::testpolicycfns3vpc/*' Condition: StringEquals: aws:PrincipalOrgID: x-xxxxxxx
Refrence links : https://aws.amazon.com/blogs/security/control-access-to-aws-resources-by-using-the-aws-organization-of-iam-principals/
You might be better off using this Centralized Flow Logs solution: https://aws.amazon.com/blogs/mt/vpc-flow-log-with-aws-control-tower-lifecycle/
Use below bucket Policy with aws:ResourceOrgID condition.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AWSLogDeliveryWrite",
"Effect": "Allow",
"Principal": {
"Service": "delivery.logs.amazonaws.com"
},
"Action": [
"s3:PutObject",
"s3:GetBucketAcl",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::bucket_name/*”,
"arn:aws:s3:::bucket_name"
],
"Condition": {
"StringEquals": {
"aws:ResourceOrgID": “o-xyzz"
}
}
}
]
}
Your policy locks down access to the bucket that exists in org o-xyzz not log delivery from org o-xyzz
This does not work
Just get rid of the service principal:
{
"Version": "2012-10-17",
"Statement": [
{
"Principal": "*",
"Action": "s3:PutObject",
"Resource": [
"arn:aws:s3:::flow-logs-bucket/*"
],
"Effect": "Allow",
"Condition": {
"StringEquals": {
"aws:PrincipalOrgID": "o-aaa123bbb456",
"s3:x-amz-acl":"bucket-owner-full-control"
}
}
}
]
}
I wouldnt use Principal * as this grants all users and accounts within your Organisiation PutObject to the bucket. Nor does it follow least privilege
Hello,
You can use "aws:ResourceOrgID" condition statement with the same and that should be working with your usecase. This lets the service related principals to only do mentioned actions when the resource org equals to the org id of the organization. You can use a condition as this -> "aws:ResourceOrgID": "${aws:PrincipalOrgID}"
Here is the documentation -> https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-resourceorgid
Service principals are not part of your org.
Relevant content
- asked 2 years ago
- asked 3 months ago
- asked 2 years ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 9 months ago
Were you able to figure this one out? I tested the solution of the following but that puts the principal to be over permissive
: https://aws.amazon.com/blogs/security/control-access-to-aws-resources-by-using-the-aws-organization-of-iam-principals/ if you have any idea however ideally we'd prevent one account overwriting another account's data, how can i make more cahnges to the following policy to be able to follow principle of least privilege ?