I want to troubleshoot 403 Access Denied errors from Amazon Simple Storage Service (Amazon S3) when creating a resource data sync.
Resolution
To resolve a "S3 write failed for bucket" error, use one of the following methods to configure resource data sync for AWS Systems Manager inventory:
- Create a resource data sync for multiple accounts within the same organization.
- Create a resource data sync for multiple accounts that aren't within the same organization.
Resolve "S3 write failed" errors for multiple accounts within the same organization
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.
Make sure that the central Amazon S3 bucket policy has the required permissions to allow multiple AWS accounts to send inventory data to the bucket. The following example policy includes the necessary permissions:
{
"Version":"2012-10-17",
"Statement": [
{
"Sid": "SSMBucketPermissionsCheck",
"Effect": "Allow",
"Principal": {
"Service": "ssm.amazonaws.com"
},
"Action": "s3:GetBucketAcl",
"Resource": "arn:aws:s3:::example-bucket-name"
},
{
"Sid": " SSMBucketDelivery",
"Effect": "Allow",
"Principal": {
"Service": "ssm.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": [
"arn:aws:s3:::example-bucket-name/example-prefix-name/*/accountid=*/*"
],
"Condition": {
"StringEquals": {
"s3:x-amz-acl": "bucket-owner-full-control",
"aws:SourceOrgID": "example-organization-id"
}
}
},
{
"Sid": " SSMBucketDeliveryTagging",
"Effect": "Allow",
"Principal": {
"Service": "ssm.amazonaws.com"
},
"Action": "s3:PutObjectTagging",
"Resource": [
"arn:aws:s3:::example-bucket-name/example-prefix-name/*/accountid=*/*"
]
}
]
}
Note: Replace example- values with your values.
You can't create a resource data sync from the AWS Management Console when the resource data sync is for multiple accounts within the same organization.
To create a resource data sync for multiple accounts within the same organization, run the following CreateResourceDataSync API call in AWS CLI. Be sure to specify the DestinationDataSharing parameter:
aws ssm create-resource-data-sync --sync-name example-name --s3-destination "BucketName=example-bucket-name,Prefix=example-prefix-name,SyncFormat=JsonSerDe,Region=example-region-id,DestinationDataSharing={DestinationDataSharingType=Organization}"
Note: Replace example- values with your values.
To confirm that you included the DestinationDataSharing parameter, in AWS CloudTrail, check the API request for the CreateResourceDataSync event name.
Resolve "S3 write failed" for multiple accounts that aren't within the same organization
To create a resource data sync, confirm that the S3 bucket policy of the target S3 bucket allows the required actions from the source account.
For example, you have Account A and Account B sending the inventory data to an S3 bucket in Account C.
The S3 bucket policy in Account C is similar to the following example policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "SSMBucketPermissionsCheck",
"Effect": "Allow",
"Principal": {
"Service": "ssm.amazonaws.com"
},
"Action": "s3:GetBucketAcl",
"Resource": "arn:aws:s3:::example-bucket-name"
},
{
"Sid": "SSMBucketDelivery",
"Effect": "Allow",
"Principal": {
"Service": "ssm.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": [
"arn:aws:s3:::example-bucket-name/*/accountid=example-account-a-id/*",
"arn:aws:s3:::example-bucket-name/*/accountid=example-account-b-id/*"
],
"Condition": {
"StringEquals": {
"aws:SourceAccount": [
"example-account-a-id",
"example-account-b-id"
],
"s3:x-amz-acl": "bucket-owner-full-control"
},
"ArnLike": {
"aws:SourceArn": [
"arn:aws:ssm:*:example-account-a-id:resource-data-sync/*",
"arn:aws:ssm:*:example-account-b-id:resource-data-sync/*"
]
}
}
}
]
}
Note: Replace example- values with your values.
To encrypt the resource data sync, be sure to update the AWS Key Management Service (AWS KMS) key policy and S3 bucket policy. For more information, see Walkthrough: Use resource data sync to aggregate inventory data.