Centralise SSM inventory for an organization

Hi,

I want to get all SSM inventory (and later patch) information across the organisation to one bucket. I created the bucket, and configured permissions, as details here.

The problem I have is actually creating the datasync. The page has the following example:

aws ssm create-resource-data-sync --sync-name name --s3-destination “BucketName=DOC-EXAMPLE-BUCKET,Prefix=prefix-name,SyncFormat=JsonSerDe,Region=AWS Region, for example us-east-2,DestinationDataSharing={DestinationDataSharingType=Organization}”

When I change the bucket name and region, I get the following error:

An error occurred (ResourceDataSyncInvalidConfigurationException) when calling the CreateResourceDataSync operation: Organization Id is required when DestinationDataSharing is selected in S3Destination

I can’t find anything about specifying an org ID anywhere in the documentation.

Has anyone got this configured successfully?

Check sync-source parameter
“create-resource-data-sync — AWS CLI 1.19.69 Command Reference” https://docs.aws.amazon.com/cli/latest/reference/ssm/create-resource-data-sync.html

Thanks. Have you actually got this to work? Is I use SyncFromSource, it sounds like it need to run it in the org account, but the AWS documentation talks about it running the cli in all accounts in all regions?

So I have created a JSON file that contains:

{
“SyncName”: “DefaultSync”,
“S3Destination”: {
“BucketName”: “mybucket”,
“SyncFormat”: “JsonSerDe”,
“Region”: “us-east-1”,
“DestinationDataSharing”: {
“DestinationDataSharingType”: “Organization”
}
},
“SyncType”: “SyncFromSource”,
“SyncSource”: {
“SourceType”: “AwsOrganizations”,
“AwsOrganizationsSource”: {
“OrganizationSourceType”: “EntireOrganization”
},
“SourceRegions”: [
“us-east-1”,
“us-west-1”,
“us-west-2”,
“sa-east-1”,
“eu-west-1”,
“ap-southeast-2”,
“eu-central-1”,
“ap-southeast-1”,
“ap-northeast-1”,
“ap-south-1”,
“ap-northeast-2”,
“eu-north-1”,
“us-east-2”,
“eu-west-2”,
“eu-west-3”,
“ca-central-1”
],
“IncludeFutureRegions”: true
}
}

I then copied that up to S3, and then to the local cloudshell session in my org root account where I was able to run it.

aws s3 cp s3://bucket/org_inventory2.json org_inventory2.json
aws ssm create-resource-data-sync --cli-input-json file://org_inventory2.json

After a few attempts with previous versions of the JSON, it now completes without error, which is a good sign I think. But I don’t see anything in my S3 bucket yet..

So feel like I am getting further, but still not sure if it is not missing something?

I actually implemented this at work the other week and didnt run into any issues.. i used Terraform to deploy the configs but I did all the account/region deployments separately (we have a cicd in place) havent tried doing an org wide deployment from the master acc

Cheers, so you just ran with in each account with “SyncToDestination” as the sync type?

Bit sleepy and I might lie to you… so ill just verify in the morning and paste the exact details!.

But I believe what I did was 1. Create the inventory in each account
2. Create the data sync resource in each account

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_resource_data_sync

Saved

Not going to lie, that looks so much easier!

resource “aws_ssm_resource_data_sync” “foo” {
name = “foo” s3_destination {
bucket_name = aws_s3_bucket.hoge.bucket
region = aws_s3_bucket.hoge.region
}
}

So, got this working.

  1. Create your S3 bucket in the root account, and configure permissions for all of your other accounts.
  2. Create you inventory data-sync in each account, pointing to the s3 bucket you created above (if you get errors, check your JSON for the correct arn format)
  3. Check that you have inventory data in bucket (you may need to give it a few minutes)
  4. Then go to Athena, and create the tables and namespaces for the data you are collecting
  5. Optionally, sign up for a trial of quicksight to view it all.

This link was pretty good at sorting it all out, and of course the other comments here!

saving - this is exactly what I need to get going ASAP.