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

New Resource: aws_swf_domain #2803

Merged
merged 1 commit into from
Jul 9, 2018
Merged

New Resource: aws_swf_domain #2803

merged 1 commit into from
Jul 9, 2018

Conversation

robinjoseph08
Copy link
Contributor

#131

TF_ACC=1 go test ./aws -v -run=TestAccAwsSwfDomain_basic -timeout 120m
=== RUN   TestAccAwsSwfDomain_basic
--- PASS: TestAccAwsSwfDomain_basic (11.93s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       11.966s

@jen20 jen20 added enhancement Requests to existing resources that expand the functionality or scope. new-resource Introduces a new resource. labels Dec 31, 2017
@radeksimko radeksimko added service/route53 Issues and PRs that pertain to the route53 service. service/swf Issues and PRs that pertain to the swf service. and removed service/route53 Issues and PRs that pertain to the route53 service. labels Jan 16, 2018
@robinjoseph08
Copy link
Contributor Author

Any chance this PR will be reviewed soon? I'd love to get this in. Thanks!

@jdpaton
Copy link

jdpaton commented Mar 22, 2018

Can we get this get merged?

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 @robinjoseph08 👋 Thanks for submitting this and sorry for the delay in review 😅 Please see the below for some initial feedback. Let us know if you have any questions or do not have time to implement the feedback. Thanks!

Create: resourceAwsSwfDomainCreate,
Read: resourceAwsSwfDomainRead,
Delete: resourceAwsSwfDomainDelete,
Importer: &schema.ResourceImporter{
Copy link
Contributor

Choose a reason for hiding this comment

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

The acceptance testing is currently not exercising resource importing. To add it we can add the following TestStep to TestAccAwsSwfDomain_basic:

{
  ResourceName: "aws_swf_domain.test",
  ImportState: true,
  ImportStateVerify: true,
  ImportStateVerifyIgnore: []string{"name_prefix"}, // this line is only necessary if the test configuration is using name_prefix
},

ForceNew: true,
ConflictsWith: []string{"name_prefix"},
},
"name_prefix": &schema.Schema{
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nitpick: the &schema.Schema declaration here is unnecessary since Go 1.7 as its already defined by map[string]*schema.Schema above

The same applies to both description and workflow_execution_retention_period_in_days below.

} else {
name = resource.UniqueId()
}
d.Set("name", name)
Copy link
Contributor

Choose a reason for hiding this comment

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

The d.Set("name", name) here should be extraneous as its handled (properly) in the read function.


resp, err := conn.DescribeDomain(input)
if err != nil {
return err
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 perform a check here to allow Terraform to properly suggest recreating the resource if it is deleted outside Terraform as well as return a more helpful message about when the error occurred:

if err != nil {
  if isAWSErr(err, swf.ErrCodeUnknownResourceFault, "") {
    log.Printf("[WARN] SWF Domain %q not found, removing from state", d.Id())
    d.SetId("")
    return nil
  }
  return fmt.Errorf("error reading SWF Domain: %s", err)
}

return err
}

info := resp.DomainInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

To prevent potential panics, we should perform nil checks for the nested structures:

if resp.DomainInfo == nil || resp.DomainInfo.Configuration == nil {
  log.Printf("[WARN] SWF Domain %q not found, removing from state", d.Id())
  d.SetId("")
  return nil
}


_, err := conn.DeprecateDomain(input)
if err != nil {
return err
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 allow the resource to skip returning an error if its already been deprecated/deleted:

if err != nil {
  if isAWSErr(err, swf.ErrCodeDomainDeprecatedFault, "") {
    return nil
  }
  if isAWSErr(err, swf.ErrCodeUnknownResourceFault, "") {
    return nil
  }
  return fmt.Errorf("error deleting SWF Domain: %s", err)
}

return err
}

d.SetId("")
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nitpick: calling d.SetId("") during the delete function is extraneous

"github.com/hashicorp/terraform/terraform"
)

func TestAccAwsSwfDomain_basic(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this resource is accepting three ways to configure the name (via name, via name_prefix, and via generated ID), there should be three separate acceptance tests to cover each scenario separately.

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Jun 27, 2018
@robinjoseph08
Copy link
Contributor Author

Hey @bflad, I don't think I'll be able to get to this soon unfortunately. But anyone is free to pick it up!

@bflad bflad added this to the v1.27.0 milestone Jul 9, 2018
@bflad bflad merged commit 58e1493 into hashicorp:master Jul 9, 2018
bflad added a commit that referenced this pull request Jul 9, 2018
make testacc TEST=./aws TESTARGS='-run=TestAccAWSSwfDomain'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSSwfDomain -timeout 120m
=== RUN   TestAccAWSSwfDomain_basic
--- PASS: TestAccAWSSwfDomain_basic (13.01s)
=== RUN   TestAccAWSSwfDomain_NamePrefix
--- PASS: TestAccAWSSwfDomain_NamePrefix (11.40s)
=== RUN   TestAccAWSSwfDomain_GeneratedName
--- PASS: TestAccAWSSwfDomain_GeneratedName (12.78s)
=== RUN   TestAccAWSSwfDomain_Description
--- PASS: TestAccAWSSwfDomain_Description (11.61s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	48.829s
@bflad
Copy link
Contributor

bflad commented Jul 9, 2018

Thanks @robinjoseph08! I have addressed PR feedback in ec25406 and it passes acceptance testing:

make testacc TEST=./aws TESTARGS='-run=TestAccAWSSwfDomain'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSSwfDomain -timeout 120m
=== RUN   TestAccAWSSwfDomain_basic
--- PASS: TestAccAWSSwfDomain_basic (13.01s)
=== RUN   TestAccAWSSwfDomain_NamePrefix
--- PASS: TestAccAWSSwfDomain_NamePrefix (11.40s)
=== RUN   TestAccAWSSwfDomain_GeneratedName
--- PASS: TestAccAWSSwfDomain_GeneratedName (12.78s)
=== RUN   TestAccAWSSwfDomain_Description
--- PASS: TestAccAWSSwfDomain_Description (11.61s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	48.829s

bflad added a commit that referenced this pull request Jul 9, 2018
@bflad
Copy link
Contributor

bflad commented Jul 11, 2018

This has been released in version 1.27.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 4, 2020

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 Apr 4, 2020
@breathingdust breathingdust removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. new-resource Introduces a new resource. service/swf Issues and PRs that pertain to the swf service.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants