Skip to content

Commit

Permalink
feat(aws-s3-sqs): added loggingBucketProps in aws-s3-sqs and updated …
Browse files Browse the repository at this point in the history
…tests (#413)

* added loggingBucketProps in aws-s3-sqs and updated tests

* modifed construct prop comments

* added integ test for custom logging bucket

* removed autoDeleteObject for cfn nag scan

* added missing semicolon
  • Loading branch information
mickychetta committed Oct 1, 2021
1 parent 1552e4e commit 3ddf6ef
Show file tree
Hide file tree
Showing 7 changed files with 682 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface S3ToLambdaProps {
*/
readonly existingLambdaObj?: lambda.Function,
/**
* User provided props to override the default props for the Lambda function.
* Optional user provided props to override the default props for the Lambda function.
*
* @default - Default props are used
*/
Expand All @@ -41,7 +41,7 @@ export interface S3ToLambdaProps {
*/
readonly existingBucketObj?: s3.Bucket,
/**
* User provided props to override the default props for the S3 Bucket.
* Optional user provided props to override the default props for the S3 Bucket.
*
* @default - Default props are used
*/
Expand All @@ -53,7 +53,7 @@ export interface S3ToLambdaProps {
*/
readonly s3EventSourceProps?: S3EventSourceProps,
/**
* User provided props to override the default props for the S3 Logging Bucket.
* Optional user provided props to override the default props for the S3 Logging Bucket.
*
* @default - Default props are used
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { S3ToLambda, S3ToLambdaProps } from "../lib";
import * as lambda from '@aws-cdk/aws-lambda';
import * as s3 from '@aws-cdk/aws-s3';
import * as cdk from "@aws-cdk/core";
import * as defaults from '../../core/index';
import '@aws-cdk/assert/jest';

function deployNewFunc(stack: cdk.Stack) {
Expand Down Expand Up @@ -71,7 +70,12 @@ test("Test bad call with existingBucket and bucketProps", () => {
test('s3 bucket with bucket, loggingBucket, and auto delete objects', () => {
const stack = new cdk.Stack();

defaults.buildS3Bucket(stack, {
new S3ToLambda(stack, 's3-lambda', {
lambdaFunctionProps: {
code: lambda.Code.fromAsset(`${__dirname}/lambda`),
runtime: lambda.Runtime.NODEJS_12_X,
handler: 'index.handler'
},
bucketProps: {
removalPolicy: cdk.RemovalPolicy.DESTROY,
},
Expand All @@ -93,7 +97,7 @@ test('s3 bucket with bucket, loggingBucket, and auto delete objects', () => {
]
},
BucketName: {
Ref: "S3LoggingBucket800A2B27"
Ref: "s3lambdaS3LoggingBucketAC6FF14E"
}
});
});
13 changes: 7 additions & 6 deletions source/patterns/@aws-solutions-constructs/aws-s3-sqs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,18 @@ _Parameters_
| **Name** | **Type** | **Description** |
|:-------------|:----------------|-----------------|
|existingBucketObj?|[`s3.Bucket`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-s3.IBucket.html)|Existing instance of S3 Bucket object. If this is provided, then also providing bucketProps is an error. |
|bucketProps?|[`s3.BucketProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-s3.BucketProps.html)|User provided props to override the default props for the S3 Bucket.|
|bucketProps?|[`s3.BucketProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-s3.BucketProps.html)|Optional user provided props to override the default props for the S3 Bucket.|
|s3EventTypes?|[`s3.EventType[]`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-s3.EventType.html)|The S3 event types that will trigger the notification. Defaults to s3.EventType.OBJECT_CREATED.|
|s3EventFilters?|[`s3.NotificationKeyFilter[]`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-s3.NotificationKeyFilter.html)|S3 object key filter rules to determine which objects trigger this event. If not specified no filter rules will be applied.|
|existingQueueObj?|[`sqs.Queue`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.Queue.html)|An optional, existing SQS queue to be used instead of the default queue. Providing both this and `queueProps` will cause an error. If the SQS queue is encrypted, the KMS key utilized for encryption must be a customer managed CMK.|
|queueProps?|[`sqs.QueueProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.QueueProps.html)|Optional user-provided props to override the default props for the SQS queue.|
|deadLetterQueueProps?|[`sqs.QueueProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.QueueProps.html)|Optional user-provided props to override the default props for the dead letter SQS queue.|
|existingQueueObj?|[`sqs.Queue`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.Queue.html)|Existing SQS queue to be used instead of the default queue. Providing both this and `queueProps` will cause an error. If the SQS queue is encrypted, the KMS key utilized for encryption must be a customer managed CMK.|
|queueProps?|[`sqs.QueueProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.QueueProps.html)|Optional user provided props to override the default props for the SQS queue.|
|deadLetterQueueProps?|[`sqs.QueueProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-sqs.QueueProps.html)|Optional user provided props to override the default props for the dead letter SQS queue.|
|deployDeadLetterQueue?|`boolean`|Whether to create a secondary queue to be used as a dead letter queue. Defaults to true.|
|maxReceiveCount?|`number`|The number of times a message can be unsuccessfully dequeued before being moved to the dead letter queue. Defaults to 15.|
|enableEncryptionWithCustomerManagedKey?|`boolean`|Use a KMS Key, either managed by this CDK app, or imported. If importing an encryption key, it must be specified in the encryptionKey property for this construct.|
|encryptionKey?|[`kms.Key`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-kms.Key.html)|An optional, imported encryption key to encrypt the SQS queue.|
|encryptionKeyProps?|[`kms.KeyProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-kms.KeyProps.html)|An optional, user provided properties to override the default properties for the KMS encryption key.|
|encryptionKey?|[`kms.Key`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-kms.Key.html)|Optional imported encryption key to encrypt the SQS queue.|
|encryptionKeyProps?|[`kms.KeyProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-kms.KeyProps.html)|Optional user provided properties to override the default properties for the KMS encryption key.|
|loggingBucketProps?|[`s3.BucketProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-s3.BucketProps.html)|Optional user provided props to override the default props for the S3 Logging Bucket.|

## Pattern Properties

Expand Down
15 changes: 11 additions & 4 deletions source/patterns/@aws-solutions-constructs/aws-s3-sqs/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface S3ToSqsProps {
*/
readonly existingBucketObj?: s3.Bucket,
/**
* User provided props to override the default props for the S3 Bucket.
* Optional user provided props to override the default props for the S3 Bucket.
*
* @default - Default props are used
*/
Expand Down Expand Up @@ -86,17 +86,23 @@ export interface S3ToSqsProps {
*/
readonly enableEncryptionWithCustomerManagedKey?: boolean
/**
* An optional, imported encryption key to encrypt the SQS queue.
* Optional imported encryption key to encrypt the SQS queue.
*
* @default - not specified.
*/
readonly encryptionKey?: kms.Key,
/**
* Optional user-provided props to override the default props for the encryption key.
* Optional user provided props to override the default props for the encryption key.
*
* @default - Default props are used.
*/
readonly encryptionKeyProps?: kms.KeyProps
/**
* Optional user provided props to override the default props for the S3 Logging Bucket.
*
* @default - Default props are used
*/
readonly loggingBucketProps?: s3.BucketProps
}

/**
Expand Down Expand Up @@ -136,7 +142,8 @@ export class S3ToSqs extends Construct {
// Setup the S3 bucket
if (!props.existingBucketObj) {
[this.s3Bucket, this.s3LoggingBucket] = defaults.buildS3Bucket(this, {
bucketProps: props.bucketProps
bucketProps: props.bucketProps,
loggingBucketProps: props.loggingBucketProps
});
bucket = this.s3Bucket;
} else {
Expand Down
Loading

0 comments on commit 3ddf6ef

Please sign in to comment.