Skip to content

Instantly share code, notes, and snippets.

@alisade
Created October 27, 2025 04:39
Show Gist options
  • Save alisade/d7fdc98d2e80516cabfbdbec10aa658e to your computer and use it in GitHub Desktop.
Save alisade/d7fdc98d2e80516cabfbdbec10aa658e to your computer and use it in GitHub Desktop.
// Enable GuardDuty delegated admin
if (enableGuardDuty) {
const guardDutyPolicy = cr.AwsCustomResourcePolicy.fromStatements([
// from https://docs.aws.amazon.com/guardduty/latest/ug/organizations_permissions.html
new iam.PolicyStatement({
actions: [
'guardduty:EnableOrganizationAdminAccount',
'guardduty:ListOrganizationAdminAccounts',
'guardduty:DisableOrganizationAdminAccount',
],
resources: ['*'],
}),
new iam.PolicyStatement({
actions: [
'organizations:EnableAWSServiceAccess',
'organizations:RegisterDelegatedAdministrator',
// ******************************************************************
// * not in AWS documentation, but is needed o.w. deployment will fail
'organizations:DeregisterDelegatedAdministrator',
// ******************************************************************
'organizations:ListDelegatedAdministrators',
'organizations:ListAWSServiceAccessForOrganization',
'organizations:DescribeOrganizationalUnit',
'organizations:DescribeAccount',
'organizations:DescribeOrganization',
'organizations:ListAccounts',
],
resources: ['*'],
}),
new iam.PolicyStatement({
actions: ['iam:CreateServiceLinkedRole'],
resources: ['*'],
conditions: {
StringEquals: {
'iam:AWSServiceName': 'guardduty.amazonaws.com',
},
},
}),
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment