Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functionality to store github events in s3 bucket #85

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

bshien
Copy link
Collaborator

@bshien bshien commented Oct 8, 2024

Description

Coming from #76

  1. Added an S3 bucket
  2. Added the automation app docker container to upload github events to s3
  3. Added role for ec2 to write to s3.

Issues Resolved

Part of #57

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.57%. Comparing base (a6eb945) to head (f5a4c7f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #85      +/-   ##
============================================
+ Coverage     83.48%   83.57%   +0.09%     
  Complexity      202      202              
============================================
  Files            55       56       +1     
  Lines          1229     1236       +7     
  Branches         51       52       +1     
============================================
+ Hits           1026     1033       +7     
  Misses          181      181              
  Partials         22       22              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

super(scope, id);

this.githubEventsBucket = new Bucket(this, 'OpenSearchMetricsGithubEvents', {
bucketName: "opensearch-project-github-events",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to name the bucket? Usually it is not recommended to name the resources created via CDK. Let the CDK assign the random naming to avoid future failures.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why is it not recommended? We are indexing to this bucket in the automation app here: https://github.com/opensearch-project/automation-app/blob/main/src/call/github-events-to-s3.ts#L29

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s3 bucket names are unique globally (not just within the account but all accounts in AWS). When you name the resources, you cannot deploy multiple stacks using same CDK as it will throw an error with resource already exists. All the resources in CDK have a resource identifier or logical name but adding a resource name might not be a good idea. You can deploy the stack and use the name created by the CDK in the automation app url mentioned above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, removed the bucket name and changed the logical ID to be more specific

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other option we can go is allow the bucketName to passed as a stack props, then its upto the user to pass the bucket name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out this PR here: opensearch-project/automation-app#26

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added one comment here https://github.com/opensearch-project/automation-app/pull/26/files#r1793853695, in that case just create the bucket and update the secret. Thanks

@bshien bshien force-pushed the s3-event-sink-3 branch 2 times, most recently from bade547 to 46df9d5 Compare October 8, 2024 23:39
@@ -25,6 +25,7 @@ So you want to contribute code to this project? Excellent! We're glad you're her
- `cdk deploy OpenSearchMetrics-GitHubAutomationApp-Secret`: Creates the GitHub app secret which will be used during the GitHub app runtime.
- `cdk deploy OpenSearchMetrics-GitHubWorkflowMonitor-Alarms`: Creates the Alarms to Monitor the Critical GitHub CI workflows by the GitHub Automation App.
- `cdk deploy OpenSearchMetrics-GitHubAutomationApp`: Create the resources which launches the [GitHub Automation App](https://github.com/opensearch-project/automation-app). Listens to GitHub events and index the data to Metrics cluster.
- `cdk deploy OpenSearchMetrics-S3`: Create the S3 Bucket that will store GitHub Events.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please change this to OpenSearchMetrics-GitHubAutomationAppEvents-S3

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we can put various s3 buckets in this stack in the future, so the name should be kept general. I'll change the description to describe this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes since you added under infrastructure/lib/stacks/s3.ts it will create new stack for new s3 bucket, so the stack name is OpenSearchMetrics-GitHubAutomationAppEvents-S3. With this we have have a proper naming convention for each s3 bucket stack.
So tomorrow if you need a new s3 bucket it will be a new stack altogether.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I updated the PR to make these changes

Signed-off-by: Brandon Shien <bshien@amazon.com>
@bshien bshien merged commit f92979d into opensearch-project:main Oct 9, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants