-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added functionality to store github events in s3 bucket
Signed-off-by: Brandon Shien <bshien@amazon.com>
- Loading branch information
Showing
7 changed files
with
162 additions
and
8 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
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,29 @@ | ||
/** | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
import {Stack, RemovalPolicy, StackProps} from "aws-cdk-lib"; | ||
import { Bucket, BlockPublicAccess, BucketEncryption } from 'aws-cdk-lib/aws-s3'; | ||
import { Construct } from "constructs"; | ||
|
||
export class OpenSearchS3 extends Stack { | ||
|
||
public readonly bucket: Bucket; | ||
|
||
constructor(scope: Construct, id: string, props?: StackProps) { | ||
super(scope, id); | ||
|
||
this.bucket = new Bucket(this, 'OpenSearchS3Bucket', { | ||
publicReadAccess: false, | ||
blockPublicAccess: BlockPublicAccess.BLOCK_ALL, | ||
encryption: BucketEncryption.S3_MANAGED, | ||
enforceSSL: true, | ||
versioned: true, | ||
removalPolicy: RemovalPolicy.RETAIN, | ||
}); | ||
} | ||
} |
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,84 @@ | ||
/** | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
import { App } from "aws-cdk-lib"; | ||
import { Template } from "aws-cdk-lib/assertions"; | ||
import {OpenSearchS3} from "../lib/stacks/s3"; | ||
|
||
test('S3 Stack Test', () => { | ||
const app = new App(); | ||
const s3Stack = new OpenSearchS3(app, "Test-OpenSearchMetrics-GitHubAutomationAppEvents-S3"); | ||
const s3StackTemplate = Template.fromStack(s3Stack); | ||
s3StackTemplate.resourceCountIs('AWS::S3::Bucket', 1); | ||
s3StackTemplate.resourceCountIs('AWS::S3::BucketPolicy', 1); | ||
s3StackTemplate.hasResourceProperties('AWS::S3::Bucket', { | ||
"BucketEncryption": { | ||
"ServerSideEncryptionConfiguration": [ | ||
{ | ||
"ServerSideEncryptionByDefault": { | ||
"SSEAlgorithm": "AES256" | ||
} | ||
} | ||
] | ||
}, | ||
"PublicAccessBlockConfiguration": { | ||
"BlockPublicAcls": true, | ||
"BlockPublicPolicy": true, | ||
"IgnorePublicAcls": true, | ||
"RestrictPublicBuckets": true | ||
}, | ||
"VersioningConfiguration": { | ||
"Status": "Enabled" | ||
} | ||
}); | ||
s3StackTemplate.hasResourceProperties('AWS::S3::BucketPolicy', { | ||
"Bucket": { | ||
"Ref": "OpenSearchS3Bucket2ED683CC" | ||
}, | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "s3:*", | ||
"Condition": { | ||
"Bool": { | ||
"aws:SecureTransport": "false" | ||
} | ||
}, | ||
"Effect": "Deny", | ||
"Principal": { | ||
"AWS": "*" | ||
}, | ||
"Resource": [ | ||
{ | ||
"Fn::GetAtt": [ | ||
"OpenSearchS3Bucket2ED683CC", | ||
"Arn" | ||
] | ||
}, | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
{ | ||
"Fn::GetAtt": [ | ||
"OpenSearchS3Bucket2ED683CC", | ||
"Arn" | ||
] | ||
}, | ||
"/*" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
} | ||
}); | ||
|
||
}); |