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

Issue #7573 terraform crash - codepipeline #7587

Closed
wants to merge 1 commit into from

Conversation

saravanan30erd
Copy link
Contributor

Fixes #7573

Changes proposed in this pull request:

  • Change 1
    verifying the output before set to attr - aws_codepipeline

@ghost ghost added the size/XS Managed by automation to categorize the size of a PR. label Feb 16, 2019
@bflad bflad added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/codepipeline Issues and PRs that pertain to the codepipeline service. labels Feb 16, 2019
@bflad bflad added this to the v1.60.0 milestone Feb 16, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Hi @saravanan30erd 👋 Thanks for submitting this. I believe there is more at play here than just the two string pointers here that previously did not handle pointer safety correctly. I've asked for some clarification in the original issue (#7573).

It looks like in November last year, AWS CodePipeline released new cross-region functionality which added a new optional ArtifactStores attributes and made the previously required ArtifactStore attribute optional as well. The aws_codepipeline resource code is currently assuming that ArtifactStore is always passed back from the API response without its own nil check.

To properly fix the current situation leaves us in a little bit of a bind as this is new functionality, but assumptions about the old functionality are causing an unexpected crash. We'll need to decide if we want to do one of the following:

  • Return an error mentioning the lack of cross-region support if ArtifactStores has elements
  • Implement the multiple ArtifactsStores functionality

In either case we should properly perform a nil check for ArtifactStore itself within the flattenAwsCodePipelineArtifactStore function for good measure:

func flattenAwsCodePipelineArtifactStore(artifactStore *codepipeline.ArtifactStore) []interface{} {
	if artifactStore == nil {
		return []interface{}{}
	}
	values := map[string]interface{}{
		"location": aws.StringValue(artifactStore.Location),
		"type": aws.StringValue(artifactStore.Type),
	}
	// ...

In general, its usually helpful to find a reproducing test configuration so we can ensure we are implementing a proper fix. My best guess is that the initial fix here, while better code practice, would not actually help in this situation. Hope this makes sense.

References:

@@ -227,8 +227,12 @@ func expandAwsCodePipelineArtifactStore(d *schema.ResourceData) *codepipeline.Ar

func flattenAwsCodePipelineArtifactStore(artifactStore *codepipeline.ArtifactStore) []interface{} {
values := map[string]interface{}{}
values["type"] = *artifactStore.Type
values["location"] = *artifactStore.Location
if artifactStore.Type != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Performing a nil check before using the AWS Go SDK type conversion functions is redundant. They convert nil to the zero-value for the type: https://docs.aws.amazon.com/sdk-for-go/api/aws/#StringValue

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Feb 19, 2019
@bflad bflad removed this from the v1.60.0 milestone Feb 22, 2019
@bflad
Copy link
Contributor

bflad commented Jun 21, 2019

Closing for now given the above and no additional movement within this pull request.

@bflad bflad closed this Jun 21, 2019
@ghost
Copy link

ghost commented Nov 3, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 3, 2019
@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Nov 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/codepipeline Issues and PRs that pertain to the codepipeline service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

resource/aws_codepipeline: Crash when missing artifact_store or using multiple artifact stores
2 participants