Skip to content

Commit 93e4aca

Browse files
committed
chore: update cdkAspect to include SSM
1 parent de02b3d commit 93e4aca

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/parameters/tests/helpers/cdkAspectGrantAccess.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { IConstruct } from 'constructs';
33
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
44
import { Table } from 'aws-cdk-lib/aws-dynamodb';
55
import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
6+
import { StringParameter } from 'aws-cdk-lib/aws-ssm';
67

78
/**
89
* An aspect that grants access to resources to a Lambda function.
@@ -19,9 +20,9 @@ import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
1920
* @see {@link https://docs.aws.amazon.com/cdk/v2/guide/aspects.html|CDK Docs - Aspects}
2021
*/
2122
export class ResourceAccessGranter implements IAspect {
22-
private readonly resources: Table[] | Secret[];
23+
private readonly resources: Table[] | Secret[] | StringParameter[];
2324

24-
public constructor(resources: Table[] | Secret[]) {
25+
public constructor(resources: Table[] | Secret[] | StringParameter[]) {
2526
this.resources = resources;
2627
}
2728

@@ -30,11 +31,14 @@ export class ResourceAccessGranter implements IAspect {
3031
if (node instanceof NodejsFunction) {
3132

3233
// Grant access to the resources
33-
this.resources.forEach((resource: Table | Secret) => {
34+
this.resources.forEach((resource: Table | Secret | StringParameter) => {
3435

3536
if (resource instanceof Table) {
3637
resource.grantReadData(node);
37-
} else if (resource instanceof Secret) {
38+
} else if (
39+
resource instanceof Secret ||
40+
resource instanceof StringParameter
41+
) {
3842
resource.grantRead(node);
3943
}
4044

0 commit comments

Comments
 (0)