Skip to content

Commit a4f0c9b

Browse files
authored
Updates to the CDK stack to support the S3 sink integration tests. (#6662)
Exports the resources and grants permissions so that the integration tests on GitHub can pull in the exports. Also grants read permissions to the S3 bucket since the tests need to read to verify the results. Signed-off-by: David Venable <dlv@amazon.com>
1 parent 3a931a5 commit a4f0c9b

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

testing/aws-testing-cdk/lib/common/GitHubAccessStack.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/*
22
* Copyright OpenSearch Contributors
33
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
48
*/
59

610
import {Stack, StackProps} from 'aws-cdk-lib';
@@ -10,6 +14,7 @@ import {
1014
CompositePrincipal,
1115
OpenIdConnectPrincipal,
1216
OpenIdConnectProvider,
17+
PolicyStatement,
1318
Role
1419
} from 'aws-cdk-lib/aws-iam'
1520

@@ -57,5 +62,10 @@ export class GitHubAccessStack extends Stack {
5762
currentAccountPrincipal
5863
)
5964
});
65+
66+
this.gitHubActionsTestingRole.addToPolicy(new PolicyStatement({
67+
actions: ['cloudformation:DescribeStacks'],
68+
resources: [`arn:aws:cloudformation:*:${this.account}:stack/*`],
69+
}));
6070
}
6171
}

testing/aws-testing-cdk/lib/common/KmsStack.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
/*
22
* Copyright OpenSearch Contributors
33
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
48
*/
59

6-
import {Stack, StackProps} from 'aws-cdk-lib';
10+
import {CfnOutput, Stack, StackProps} from 'aws-cdk-lib';
711
import {Construct} from 'constructs';
812
import {Role} from 'aws-cdk-lib/aws-iam';
913
import {Key} from 'aws-cdk-lib/aws-kms';
@@ -27,6 +31,11 @@ export class KmsStack extends Stack {
2731
});
2832

2933
this.kmsKey.grantEncryptDecrypt(props.testingRole)
34+
35+
new CfnOutput(this, 'KmsKeyId', {
36+
value: this.kmsKey.keyArn,
37+
exportName: 'DataPrepperAwsTesting-KmsKeyId',
38+
});
3039
}
3140
}
3241

testing/aws-testing-cdk/lib/s3/S3SinkStack.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
/*
22
* Copyright OpenSearch Contributors
33
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* The OpenSearch Contributors require contributions made to
6+
* this file be licensed under the Apache-2.0 license or a
7+
* compatible open source license.
48
*/
59

6-
import {Duration, RemovalPolicy, Stack, StackProps} from 'aws-cdk-lib';
10+
import {CfnOutput, Duration, RemovalPolicy, Stack, StackProps} from 'aws-cdk-lib';
711
import {Construct} from 'constructs';
812
import {Role} from 'aws-cdk-lib/aws-iam';
913
import {Bucket} from 'aws-cdk-lib/aws-s3';
@@ -13,7 +17,7 @@ export interface S3SinkStackProps extends StackProps {
1317
}
1418

1519
/**
16-
* CDK stack that creates a common KMS key.
20+
* CDK stack for resources needed by the S3 sink integration tests.
1721
*/
1822
export class S3SinkStack extends Stack {
1923
readonly bucket: Bucket;
@@ -30,7 +34,12 @@ export class S3SinkStack extends Stack {
3034
]
3135
});
3236

33-
this.bucket.grantWrite(props.testingRole)
37+
this.bucket.grantReadWrite(props.testingRole)
38+
39+
new CfnOutput(this, 'BucketName', {
40+
value: this.bucket.bucketName,
41+
exportName: 'DataPrepperAwsTesting-S3SinkBucketName',
42+
});
3443
}
3544
}
3645

0 commit comments

Comments
 (0)