Skip to content

Commit

Permalink
Merge pull request #907 from RenovoSolutions/iamfix
Browse files Browse the repository at this point in the history
fix: IAM policy paths for parameters and secrets are incorrect
  • Loading branch information
bmiller08 authored Jun 18, 2024
2 parents 1f3f300 + 7802534 commit e3815d0
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 110 deletions.
1 change: 0 additions & 1 deletion .gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 0 additions & 90 deletions .github/workflows/upgrade-master.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .projen/files.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const project = new awscdk.AwsCdkConstructLibrary({
],
depsUpgrade: true,
depsUpgradeOptions: {
workflow: true,
workflow: false,
exclude: ['projen'],
workflowOptions: {
schedule: javascript.UpgradeDependenciesSchedule.WEEKLY,
Expand Down
5 changes: 3 additions & 2 deletions src/storage-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
aws_iam as iam,
aws_kms as kms,
Stack,
} from 'aws-cdk-lib';
import { Construct } from 'constructs';

Expand Down Expand Up @@ -37,7 +38,7 @@ export function configureSecretsManagerStorage(scope: Construct, props: SecretsM
'secretsmanager:UpdateSecret',
],
resources: [
`${props.secretsManagerPath}*`,
`arn:aws:secretsmanager:${Stack.of(scope).region}:${Stack.of(scope).account}:secret:${props.secretsManagerPath}*`,
],
}),
new iam.PolicyStatement({
Expand Down Expand Up @@ -80,7 +81,7 @@ export function configureSSMStorage(scope: Construct, props: SsmStorageProps): v
'ssm:PutParameter',
],
resources: [
`${props.parameterStorePath}*`,
`arn:aws:ssm:${Stack.of(scope).region}:${Stack.of(scope).account}:parameter${props.parameterStorePath}*`,
],
}),
new iam.PolicyStatement({
Expand Down
20 changes: 10 additions & 10 deletions test/__snapshots__/certbot.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions test/certbot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ test('stack should contain no bucket when secrets manager is used and have appro
'secretsmanager:UpdateSecret',
]),
Effect: 'Allow',
Resource: Match.stringLikeRegexp('\/certbot\/certificates\/test.local\/.*'),
Resource: Match.stringLikeRegexp('arn:aws:secretsmanager:us-east-1:123456789012:secret:\/certbot\/certificates\/test.local\/.*'),
},
{
Action: Match.arrayWith([
Expand Down Expand Up @@ -272,7 +272,7 @@ test('stack should have policy with specific resource path when path is given fo
'secretsmanager:UpdateSecret',
]),
Effect: 'Allow',
Resource: Match.stringLikeRegexp('\/certbot\/alternate\/path\/.*'),
Resource: Match.stringLikeRegexp('arn:aws:secretsmanager:us-east-1:123456789012:secret:\/certbot\/alternate\/path\/.*'),
},
{
Action: Match.arrayWith([
Expand Down Expand Up @@ -321,7 +321,7 @@ test('stack should contain no bucket when parameter store is used and have appro
{
Action: 'ssm:PutParameter',
Effect: 'Allow',
Resource: Match.stringLikeRegexp('\/certbot\/certificates\/test.local\/.*'),
Resource: Match.stringLikeRegexp('arn:aws:ssm:us-east-1:123456789012:parameter\/certbot\/certificates\/test.local\/.*'),
},
{
Action: Match.arrayWith([
Expand Down Expand Up @@ -372,7 +372,7 @@ test('stack should have policy with specific resource path when path is given fo
{
Action: 'ssm:PutParameter',
Effect: 'Allow',
Resource: Match.stringLikeRegexp('\/certbot\/alternate\/path\/.*'),
Resource: Match.stringLikeRegexp('arn:aws:ssm:us-east-1:123456789012:parameter\/certbot\/alternate\/path\/.*'),
},
{
Action: Match.arrayWith([
Expand Down

0 comments on commit e3815d0

Please sign in to comment.