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

feat(s3): constructs factories - create well architected s3 buckets #1110

Merged
merged 11 commits into from
Apr 24, 2024

Conversation

biffgaut
Copy link
Contributor

Description of changes:
This PR introduces a brand new functionality in Solutions Constructs - Constructs Factories. All Solutions Constructs are built upon our underlying core library which creates well architected resources from a single service (which our L3 Solutions Constructs then connect). Constructs Factories expose our core library functionality in a documented, supported way and is the preferred way to access the functionality in our core library.

This first release creates a factory for S3 buckets, allowing creation of a bucket following all best practices with a single call. We plan to add SQS queues and Step Functions state machines in the near future.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: githubautobuild-for-cdk-v2
  • Commit ID: 7134778
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: githubautobuild-for-cdk-v2
  • Commit ID: d5dd0a2
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: githubautobuild-for-cdk-v2
  • Commit ID: 69fdc8f
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: githubautobuild-for-cdk-v2
  • Commit ID: 6309dd1
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

georgebearden
georgebearden previously approved these changes Apr 23, 2024
Copy link
Contributor

@georgebearden georgebearden left a comment

Choose a reason for hiding this comment

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

Few comments to think about, but overall - lgtm.

Comment on lines +19 to +29
export interface S3BucketFactoryProps {
readonly bucketProps?: s3.BucketProps | any,
readonly logS3AccessLogs?: boolean,
readonly loggingBucketProps?: s3.BucketProps,
}

// Create a response specifically for the interface to avoid coupling client with internal implementation
export interface S3BucketFactoryResponse {
readonly s3Bucket: s3.Bucket,
readonly s3LoggingBucket?: s3.Bucket,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just a house keeping thing, but over time this list of inputs/outputs to the factories will get very large. Would it make more sense to move them to their own file, one file for each set? Just something to contemplate, not even sure if its the right answer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about that - this approach will become absolutely unmanageable as we expose more factories and must change. But I postponed devising an approach to handle multiple factories until I had more examples (rather than trying to come up with the generic from a single example).

Comment on lines 37 to 39
if (props) {
defaults.CheckS3Props(props);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice if defaults.CheckS3Props could handle undefined, to avoid having to put these calls in the factory methods.

Comment on lines +42 to +44
bucketProps: props.bucketProps,
loggingBucketProps: props.loggingBucketProps,
logS3AccessLogs: props.logS3AccessLogs,
Copy link
Contributor

Choose a reason for hiding this comment

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

as these fields are exactly the same, would we want to use the spread operator instead to simplify the logic?

const propsArg: defaults.BuildS3BucketProps = props ? { ...props } : {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, they are the same - but is that an fundamental trait or a coincidence? The factory is supposed to put an abstraction over the core function - feels like using the spread operator because of the coincidence will increase coupling between the exposed factory interface and the core function.

"repository": {
"type": "git",
"url": "https://github.com/awslabs/aws-solutions-constructs.git",
"directory": "source/patterns/@aws-solutions-constructs/aws-dynamodbstreams-lambda"
Copy link
Contributor

Choose a reason for hiding this comment

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

this directory looks wrong "aws-dynamodbstreams-lambda"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed

@@ -173,6 +173,7 @@ export interface BuildS3BucketResponse {

/**
* @internal This is an internal core function and should not be called directly by Solutions Constructs clients.
* @internal This functionality is exposed externally through aws-constructs-factories
Copy link
Contributor

Choose a reason for hiding this comment

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

nice comment for redirection

@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: githubautobuild-for-cdk-v2
  • Commit ID: e00f915
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@@ -18,6 +18,8 @@

The core library includes the basic building blocks of the AWS Solutions Constructs Library. It defines the core classes that are used in the rest of the AWS Solutions Constructs Library.

> NOTE: Functions in the core library are not part of the published interface for Solutions Constructs. While they are not hidden, using them directly can result in breaking changes outside the scope of a Major release. As many users have expressed an interest in accessing this functionality, we are in the process of exposing this functionality through factories that will produce individual well architected resources. Find the current state of this effort under `aws-constructs-factories`.
Copy link
Contributor

@hayesry hayesry Apr 24, 2024

Choose a reason for hiding this comment

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

super nit: can remove one of the two spaces between "Major" and "release" in "Major release"

Copy link
Contributor

@hayesry hayesry left a comment

Choose a reason for hiding this comment

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

Looks good, no concerns from my end. Test coverage is good, covers different use patterns with sensible assertions. Verified no required props on the S3Bucket that we should be aware of that might get in the way of using the construct at this level. If something presents, we can address it as part of an issue but all core functionality seems to be easily override-able by the user if needed. Able to discuss any aspects further, but I'm happy with this so far. Nice work 👍

(Let me know if I should approve or if you're just seeking comment-based feedback at this point in time)

hayesry
hayesry previously approved these changes Apr 24, 2024
@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: githubautobuild-for-cdk-v2
  • Commit ID: 6ef10df
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: githubautobuild-for-cdk-v2
  • Commit ID: 8c0ac63
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@biffgaut biffgaut merged commit f561cf6 into main Apr 24, 2024
2 checks passed
@biffgaut biffgaut deleted the ConstructsFactories branch April 24, 2024 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants