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

fix (Change log group references to ILogGroup, don't create a second log group in aws-*-step-function) #211

Merged
merged 5 commits into from
Jun 4, 2021

Conversation

biffgaut
Copy link
Contributor

@biffgaut biffgaut commented Jun 4, 2021

*Issue #, if available:*193

Description of changes:
This revealed a larger bug in the Step Functions constructs. The construct was not looking at stateMachineProps.logs to see if an existing log group had been provided and created a new log group every time. This means that there was no way to provide an existing log group. We decided to fix this even though it it may be a breaking change for outlying use cases.

The issue is that stateMachineProps.logs is ILogGroup, not LogGroup. Since ILogGroup cannot be upgraded to LogGroup, including stateMachineProps.logs as a source of log group meant that all references to Log Groups have to be converted to ILogGroup, including the properties of the constructs.

If you access the Log Group of a Step Functions construct, you may need to change the type to ILogGroup if you ever explicitly specify the type.

If you access the Log Group of a Step Functions construct and make any changes to the Log Group after the construct has been instantiated, your code will no longer work as ILogGroups cannot be altered. Your workaround will be to create a log group to your full specification before launching the Step Functions construct, the set the stateMachineProps.logs.destination to this new log group (a LogGroup object can be "downgraded" to an ILogGroup).

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

@biffgaut biffgaut requested a review from hnishar as a code owner June 4, 2021 19:11
@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: codebuildgithubautobuildPro-fkVQbXRiQi6A
  • Commit ID: a976fe0
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@biffgaut biffgaut requested a review from hayesry June 4, 2021 19:16
@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: codebuildgithubautobuildPro-fkVQbXRiQi6A
  • Commit ID: 39ba8ef
  • 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-fkVQbXRiQi6A
  • Commit ID: eca4c16
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@@ -74,7 +74,7 @@ _Parameters_
|:-------------|:----------------|-----------------|
|lambdaFunction|[`lambda.Function`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda.Function.html)|Returns an instance of the Lambda function created by the pattern.|
|stateMachine|[`sfn.StateMachine`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-stepfunctions.StateMachine.html)|Returns an instance of StateMachine created by the construct.|
|stateMachineLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for StateMachine|
|stateMachineLogGroup|[`logs.ILogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.ILogGroup.html)|Returns an instance of the LogGroup created by the construct for StateMachine|
Copy link
Contributor

@hayesry hayesry Jun 4, 2021

Choose a reason for hiding this comment

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

We should update the property description to reference ILogGroup here as well (i.e. "Returns an instance of the ILogGroup created by the construct for the StateMachine.").

@hayesry hayesry self-requested a review June 4, 2021 19:53
@aws-solutions-constructs-team
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: codebuildgithubautobuildPro-fkVQbXRiQi6A
  • Commit ID: 0b66e6d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

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.

Reviewed all files in the pull request. Helper function code looks good. Test coverage appears to be under 80% for the helper however. Recommend updating/organizing the test suite for the helper to more explicitly assert the outcomes for each of the four possibilities here (logGroup provided in stateMachineProps, logGroupProps not provided, logGroupProps provided w/o logGroupName, and logGroupProps provided w/ logGroupName). Overall nice, concise fix!

@@ -70,7 +70,7 @@ _Parameters_
| **Name** | **Type** | **Description** |
|:-------------|:----------------|-----------------|
|stateMachine|[`sfn.StateMachine`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-stepfunctions.StateMachine.html)|Returns an instance of sfn.StateMachine created by the construct|
|stateMachineLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for StateMachine|
|stateMachineLogGroup|[`logs.ILogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.ILogGroup.html)|Returns an instance of the LogGroup created by the construct for StateMachine|
Copy link
Contributor

Choose a reason for hiding this comment

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

Recommend same description update as noted for aws-lambda-stepfunction.

@@ -70,7 +70,7 @@ _Parameters_
|:-------------|:----------------|-----------------|
|eventsRule|[`events.Rule`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-events.Rule.html)|Returns an instance of events.Rule created by the construct|
|stateMachine|[`sfn.StateMachine`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-stepfunctions.StateMachine.html)|Returns an instance of sfn.StateMachine created by the construct|
|stateMachineLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for StateMachine|
|stateMachineLogGroup|[`logs.ILogGroup`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-logs.ILogGroup.html)|Returns an instance of the LogGroup created by the construct for StateMachine|
Copy link
Contributor

Choose a reason for hiding this comment

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

We should update the property description to reference ILogGroup here as well (i.e. "Returns an instance of the ILogGroup created by the construct for the StateMachine.").

@hayesry hayesry self-requested a review June 4, 2021 20:38
@biffgaut biffgaut merged commit 48d6c3e into main Jun 4, 2021
@biffgaut biffgaut deleted the Issue193 branch June 4, 2021 20:41
@biffgaut
Copy link
Contributor Author

biffgaut commented Jun 4, 2021

Approved by Ryan, Hitendra is OOTO.

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.

3 participants