-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2063 from vrk-kpa/AV-2067_create_test_bucket_and_…
…role AV-2067: create test bucket and role
- Loading branch information
Showing
6 changed files
with
109 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {StackProps} from "aws-cdk-lib"; | ||
|
||
export interface CiTestStackProps extends StackProps { | ||
testBucketName: string, | ||
githubOrg: string, | ||
githubRepo: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {aws_iam, aws_s3, Duration, Stack} from "aws-cdk-lib"; | ||
import {Construct} from "constructs"; | ||
import {CiTestStackProps} from "./ci-test-stack-props"; | ||
|
||
export class CiTestStack extends Stack { | ||
constructor(scope: Construct, id: string, props: CiTestStackProps) { | ||
super(scope, id, props); | ||
|
||
const testBucket = new aws_s3.Bucket(this,'TestBucket', { | ||
bucketName: props.testBucketName, | ||
blockPublicAccess: aws_s3.BlockPublicAccess.BLOCK_ALL, | ||
lifecycleRules: [ | ||
{ | ||
expiration: Duration.days(1) | ||
} | ||
] | ||
}) | ||
|
||
const oidcProviderArn = Stack.of(this).formatArn({ | ||
region: "", | ||
partition: "aws", | ||
resource: "oidc-provider", | ||
service: "iam", | ||
resourceName: "token.actions.githubusercontent.com" | ||
}) | ||
|
||
const testRole = new aws_iam.Role(this, 'TestRole', { | ||
assumedBy: new aws_iam.WebIdentityPrincipal(oidcProviderArn, { | ||
StringLike: { | ||
"token.actions.githubusercontent.com:sub": `repo:${props.githubOrg}/${props.githubRepo}:*` | ||
} | ||
}) | ||
}) | ||
|
||
testBucket.grantWrite(testRole) | ||
testBucket.grantRead(testRole) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# build args | ||
# build args | ||
ARG SECRET_NPMRC | ||
|
||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters