Secrets Manager Secret Publicly Accessible
secrets-manager-rotation-disabled
What this rule checks
Detects Secrets Manager secrets whose resource policy grants access to a wildcard or public principal.
How to fix it
- 1Remove wildcard/public principals from the secret resource policy
- 2Scope access to specific IAM principals or accounts
import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
import { PolicyStatement, Effect, AnyPrincipal } from 'aws-cdk-lib/aws-iam';
const secret = new Secret(this, 'DbSecret');
secret.addToResourcePolicy(new PolicyStatement({
effect: Effect.ALLOW,
principals: [new AnyPrincipal()],
actions: ['secretsmanager:GetSecretValue'],
resources: ['*'],
}));import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
import { Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
const role = new Role(this, 'AppServiceRole', { assumedBy: new ServicePrincipal('lambda.amazonaws.com') });
const secret = new Secret(this, 'DbSecret');
secret.grantRead(role);CDK Insights pinpoints the exact file and line in your CDK source for every finding, so you can jump straight to the fix.
Affected resource types
AWS::SecretsManager::ResourcePolicyIntentional? Suppress this finding
Sometimes a flag is deliberate — a genuinely public endpoint, say. You can dismiss secrets-manager-rotation-disabled and the reason is kept in the report, not silently hidden.
In .cdk-insights.json:
{
"ignoreRules": [
{ "id": "secrets-manager-rotation-disabled", "reason": "Why this is intentional" }
]
}Or inline in your CDK code:
Validations.of(scope).acknowledge({
id: 'cdk-insights::secrets-manager-rotation-disabled',
reason: 'Why this is intentional',
});Use the rule ID secrets-manager-rotation-disabled shown above — not the CDK-* ID from SARIF / GitHub code scanning. To dismiss every finding on one construct instead, use ignorePaths. Suppression docs →
Catch this in your stack
$ npx cdk-insights scanCDK Insights runs this and 118+ other rules locally against your synthesised CDK app — free, no account, your code never leaves your machine.