-
Notifications
You must be signed in to change notification settings - Fork 249
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
chore(core): change helper functions to return response objects #904
Conversation
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, it looks good to me. Just a handful of minor comments.
existingTableObj: props.existingTableObj, | ||
dynamoTableProps: props.dynamoTableProps | ||
})[1] as dynamodb.Table; | ||
}); | ||
this.dynamoTable = buildDynamoDBTableResponse.tableObject!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I first read this, I asked myself "If we know the tableObject is never null, why not change the helper to return that". After going through the whole review it makes sense why this was done with the !
operator where possible. Nice check!
@@ -21,12 +21,12 @@ const app = new App(); | |||
const stack = new Stack(app, generateIntegStackName(__filename)); | |||
|
|||
const existingTopicEncryptionKey = defaults.buildEncryptionKey(stack, {}); | |||
const [ existingTopicObj ] = defaults.buildTopic(stack, { | |||
const buildTopicRepsponse = defaults.buildTopic(stack, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit - typo buildTopicResponse
encryptionKey: existingTopicEncryptionKey | ||
}); | ||
|
||
new S3ToSns(stack, 'test-s3-sns', { | ||
existingTopicObj, | ||
existingTopicObj: buildTopicRepsponse.topic, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
@@ -15,7 +15,7 @@ | |||
import * as logs from 'aws-cdk-lib/aws-logs'; | |||
import * as lambda from 'aws-cdk-lib/aws-lambda'; | |||
import * as cdk from 'aws-cdk-lib'; | |||
import * as api from 'aws-cdk-lib/aws-apigateway'; | |||
import * as apig from 'aws-cdk-lib/aws-apigateway'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor and don't necessarily need to change, but api
and apig
are still really close when looking at the code. I would prefer this import to be apigateway
(which also matches the convention of the other imports in this file.
export function CloudFrontDistributionForApiGateway(scope: Construct, | ||
apiEndPoint: api.RestApi, | ||
cloudFrontDistributionProps?: cloudfront.DistributionProps | any, | ||
httpSecurityHeaders: boolean = true, | ||
cloudFrontLoggingBucketProps?: s3.BucketProps, | ||
responseHeadersPolicyProps?: cloudfront.ResponseHeadersPolicyProps | ||
): [cloudfront.Distribution, cloudfront.Function?, s3.Bucket?] { | ||
): CloudFrontDistributionForApiGatewayResponse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR as a whole is great, and I really like this change!
@@ -190,7 +208,7 @@ export function CloudFrontDistributionForMediaStore(scope: Construct, | |||
const cfDistribution = new cloudfront.Distribution(scope, 'CloudFrontDistribution', cfprops); | |||
updateSecurityPolicy(cfDistribution); | |||
|
|||
return [cfDistribution, loggingBucket, originRequestPolicy, cloudfrontFunction]; | |||
return { distribution: cfDistribution, loggingBucket, requestPolicy: originRequestPolicy, cloudfrontFunction}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit - space before the closing }
const deployGlueJobResponse = | ||
deployGlueJob(scope, props.glueJobProps, props.database!, props.table!, props.outputDataStore!, props.etlCodeAsset); | ||
return { | ||
job: deployGlueJobResponse.job, | ||
role: deployGlueJobResponse.role, | ||
bucket: deployGlueJobResponse.bucket, | ||
loggingBucket: deployGlueJobResponse.loggingBucket }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be simplified to just:
return deployGlueJob(scope, props.glueJobProps, props.database!, props.table!, props.outputDataStore!, props.etlCodeAsset);
The fields look the same at a glance, but maybe they aren't the same types or something, let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would work and is what happened in the past. But they are different types that coincidentally have the same attributes. To return one type in place of the other because we can currently get away with it would be brittle and couple the two routines.
export function deployGlueJob(scope: Construct, glueJobProps: glue.CfnJobProps, database: glue.CfnDatabase, table: glue.CfnTable, | ||
outputDataStore: SinkDataStoreProps, etlCodeAsset?: s3assets.Asset): [glue.CfnJob, IRole, [Bucket, (Bucket | undefined)?]] { | ||
outputDataStore: SinkDataStoreProps, etlCodeAsset?: s3assets.Asset): DeployGlueJobResponse { | ||
// TODO - replicate [glue.CfnJob, IRole, [Bucket, (Bucket | undefined)?]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what this TODO means? Let's add some more details so it makes sense to the next person, or clean it up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just got left behind, the work was done. I will remove.
@@ -143,57 +165,57 @@ export function deployGlueJob(scope: Construct, glueJobProps: glue.CfnJobProps, | |||
] | |||
}); | |||
|
|||
let _jobRole: IRole; | |||
let jobRole: IRole; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you prefer to define jobRole as const
const jobRole = glueJobProps.role ? Role.fromRoleArn(scope, 'JobRole', glueJobProps.role) : defaults.createGlueJobRole(scope);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but formatting differently for clarity
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me.
Issue #, if available:
Closes #853
Description of changes:
Many helper functions currently return arrays of anonymous values. This is error prone and poorly self-documenting. This PR attempts to change our pattern to return a Response object with explicitly named attributes.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.