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(aws-s3-sqs): New aws-s3-sqs pattern implementation (#27) #105

Merged
merged 8 commits into from
Dec 16, 2020

Conversation

danielmatuki
Copy link
Contributor

closes #27

Issue #, if available: #27

Description of changes:
Implements the AWS Solutions Construct that creates an Amazon S3 Bucket connected to an Amazon SQS queue.
In addition, it includes the changes in the s3-bucket-defaults.ts to define the defaultS3NotificationEventTypes.

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: codebuildgithubautobuildPro-rp7jMDIK1wBN
  • Commit ID: 1089629
  • 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: codebuildgithubautobuildPro-rp7jMDIK1wBN
  • Commit ID: bc37eed
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

Copy link
Contributor

@hnishar hnishar left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, main feedback is around how the KMS Key related construct props are defined and different from other similar patterns (e.g. aws-sns-sqs, aws-events-rule-sns, etc.) in the library.


| **Name** | **Type** | **Description** |
|:-------------|:----------------|-----------------|
|existingBucketObj?|[`s3.IBucket`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-s3.IBucket.html)|Existing instance of S3 Bucket object, if this is set then the bucketProps is ignored.|
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it s3.IBucket or s3.Bucket ?

});

// Setup customer managed KMS CMK for Queue encryption
let enableEncryptionWithCustomerManagedKey: boolean = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be exposed via construct props similar to aws-sns-sqs pattern ?


// Setup customer managed KMS CMK for Queue encryption
let enableEncryptionWithCustomerManagedKey: boolean = false;
if (!this.hasQueueEncryptionProperties(props.queueProps)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to aws-sns-sqs pattern, instead why not expose readonly encryptionKey?: kms.Key and readonly encryptionKeyProps?: kms.KeyProps for user to provide either Key or KeyProps ?

public readonly sqsQueue: sqs.Queue;
public readonly deadLetterQueue?: sqs.DeadLetterQueue;
public readonly s3Bucket?: s3.Bucket;
public 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.

If the Key is generated by the pattern, add it to the properties for user to access the Key

Choose a reason for hiding this comment

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

Clarifying - the encryptionKey property should be set to the key for the queue regardless of whether it was passed in or generated by the construct.

this.addCfnNagSuppress();
}

private addCfnNagSuppress() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably move to the /core since its now used by two patterns

}

// Setup the S3 bucket event notifications
s3EventTypes.forEach(type => bucket.addEventNotification(type, new s3n.SqsDestination(this.sqsQueue), ...s3Eventfilters));
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this take care of granting the KMS key permissions to S3 ?

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 it will take care of the KMS key resource policy.

@@ -0,0 +1,51 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of this Integration test ? Don't think the name integ.deployQueue.ts captures it.

existingQueueObj: queue
});
// Assertion 1
expect(SynthUtils.toCloudFormation(stack)).toMatchSnapshot();
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of snapshot, please add the targeted unit test to assert the expected resource(s) exist

existingBucketObj: myBucket
});
// Assertion 1
expect(SynthUtils.toCloudFormation(stack)).toMatchSnapshot();
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of snapshot, please add the targeted unit test to assert the expected resource(s) exist

});
// Assertion 1
expect(SynthUtils.toCloudFormation(stack)).toMatchSnapshot();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a unit test to assert the S3 is granted required permissions to use the KMS Key

Moved addCfnNagSuppress to core. Exposed encryption key properties in s3-sqs pattern. Improved integration and unit tests.
@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: codebuildgithubautobuildPro-rp7jMDIK1wBN
  • Commit ID: 84ae1b9
  • Result: FAILED
  • Build Logs (available for 30 days)

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

…source policy that allows the root account to access it.
@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: codebuildgithubautobuildPro-rp7jMDIK1wBN
  • Commit ID: f59436f
  • 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: codebuildgithubautobuildPro-rp7jMDIK1wBN
  • Commit ID: d027882
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@danielmatuki
Copy link
Contributor Author

@hnishar could you please review the changes?

@blake-enyart
Copy link

@hnishar is there anything I might be able to do to help move this along?

@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: codebuildgithubautobuildPro-rp7jMDIK1wBN
  • Commit ID: 5d9bd37
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@hnishar hnishar merged commit 80bce76 into awslabs:master Dec 16, 2020
@hnishar
Copy link
Contributor

hnishar commented Dec 16, 2020

Thanks for the contribution, the updates will go out in v1.77.0 release

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.

New Pattern: aws-s3-sqs
5 participants