Skip to content

Commit 92d7897

Browse files
committed
Make paths an array of strings
1 parent bc1c7db commit 92d7897

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/constructs/iam/fastly-logs-iam.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe("The GuFastlyLogsIamRole construct", () => {
77
const stack = simpleGuStackForTesting();
88
new GuFastlyLogsIamRole(stack, {
99
bucketName: "test",
10-
path: "TEST/stack/app/*",
10+
paths: ["TEST/stack/app/*"],
1111
});
1212
expect(Template.fromStack(stack).toJSON()).toMatchSnapshot();
1313
});

src/constructs/iam/fastly-logs-iam.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface GuFastlyLogsIamRoleProps {
1515
* @default - '*'
1616
* If paths are not specified, access will be granted to the entire S3 bucket.
1717
*/
18-
path?: string[];
18+
paths?: string[];
1919
/**
2020
* The name of the IAM role
2121
*/
@@ -36,15 +36,15 @@ export interface GuFastlyLogsIamRoleProps {
3636
* ```typescript
3737
* new GuFastlyLogsIamRole(stack, {
3838
* bucketName: "gu-mobile-logs"
39-
* path: "fastly/*"
39+
* paths: ["fastly/*"]
4040
* })
4141
* ```
4242
*
4343
* See https://docs.fastly.com/en/guides/creating-an-aws-iam-role-for-fastly-logging
4444
*/
4545
export class GuFastlyLogsIamRole extends GuRole {
4646
constructor(scope: GuStack, props: GuFastlyLogsIamRoleProps) {
47-
const { path = "*" } = props; // set defaults
47+
const { paths = ["*"] } = props; // set defaults
4848
const fastlyCustomerId = GuFastlyCustomerIdParameter.getInstance(scope).valueAsString;
4949
super(scope, "GuFastlyLogsIamRole", {
5050
assumedBy: new AccountPrincipal(FASTLY_AWS_ACCOUNT_ID),
@@ -53,7 +53,7 @@ export class GuFastlyLogsIamRole extends GuRole {
5353

5454
new GuAllowPolicy(scope, "GuFastlyLogsIamRoleAllowPolicy", {
5555
actions: ["s3:PutObject", "s3:AbortMultipartUpload"],
56-
resources: [`arn:aws:s3:::${props.bucketName}/${path}`],
56+
resources: paths.map((path) => `arn:aws:s3:::${props.bucketName}/${path}`),
5757
}).attachToRole(this);
5858
}
5959
}

0 commit comments

Comments
 (0)