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

Add tags support for resource_aws_lightsail_instance #9273

Merged
merged 1 commit into from
Jul 10, 2019

Conversation

blckct
Copy link
Contributor

@blckct blckct commented Jul 9, 2019

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Add tags support for Lightsail instances.

Release note for CHANGELOG:

resource/aws_lightsail_instance.go:  Add `tags` argument

Output from acceptance testing:

make testacc TEST=./aws TESTARGS='-run=TestAccAWSLightsailInstance_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSLightsailInstance_basic -timeout 120m
=== RUN   TestAccAWSLightsailInstance_basic
=== PAUSE TestAccAWSLightsailInstance_basic
=== CONT  TestAccAWSLightsailInstance_basic
--- PASS: TestAccAWSLightsailInstance_basic (85.64s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	85.671s

make testacc TEST=./aws TESTARGS='-run=TestDiffLightsailTags'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestDiffLightsailTags -timeout 120m
=== RUN   TestDiffLightsailTags
--- PASS: TestDiffLightsailTags (0.00s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	0.018s
...

@blckct blckct requested a review from a team July 9, 2019 00:49
@ghost ghost added size/L Managed by automation to categorize the size of a PR. service/lightsail Issues and PRs that pertain to the lightsail service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. documentation Introduces or discusses updates to documentation. labels Jul 9, 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 @blckct 👋 Thanks for contributing this. A few little things and this should be good to go. Please reach out with any questions or if you do not have time to implement the feedback items.

func resourceAwsLightsailInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).lightsailconn

if d.HasChange("tags") && !d.IsNewResource() {
Copy link
Contributor

Choose a reason for hiding this comment

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

The resource Create function does not call Update, so the d.IsNewResource() check is extraneous. 👍

Suggested change
if d.HasChange("tags") && !d.IsNewResource() {
if d.HasChange("tags") {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, copy/paste error, sorry.

@@ -32,6 +32,18 @@ func TestAccAWSLightsailInstance_basic(t *testing.T) {
resource.TestCheckResourceAttrSet("aws_lightsail_instance.lightsail_instance_test", "blueprint_id"),
resource.TestCheckResourceAttrSet("aws_lightsail_instance.lightsail_instance_test", "bundle_id"),
resource.TestCheckResourceAttrSet("aws_lightsail_instance.lightsail_instance_test", "key_pair_name"),
resource.TestCheckResourceAttr("aws_lightsail_instance.lightsail_instance_test", "tags.%", "1"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please move the tags acceptance testing to its own acceptance test function and configuration, leaving the original test configuration for the basic test and check this value is 0? Thanks!

Suggested change
resource.TestCheckResourceAttr("aws_lightsail_instance.lightsail_instance_test", "tags.%", "1"),
resource.TestCheckResourceAttr("aws_lightsail_instance.lightsail_instance_test", "tags.%", "0"),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


func testAccAWSLightsailInstanceConfig_updated(lightsailName string) string {
return fmt.Sprintf(`
provider "aws" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please note that we are trying to remove hardcoded provider configurations from the test configurations and there is a pending PR for fixing Lightsail here: #9080

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I've done it correctly this time but please check.

@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Jul 9, 2019
@bflad bflad self-assigned this Jul 9, 2019
@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Jul 9, 2019
@blckct blckct force-pushed the add_lightsail_instance_tags branch from b535616 to ad94171 Compare July 9, 2019 19:17
@blckct
Copy link
Contributor Author

blckct commented Jul 9, 2019

I've commited the code review changes and then squashed everything into one commit. Thanks for reviewing this.

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Jul 9, 2019
@bflad bflad self-requested a review July 10, 2019 00:34
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.

This looks great, thanks @blckct! 🚀

--- PASS: TestAccAWSLightsailInstance_disapear (46.38s)
--- PASS: TestAccAWSLightsailInstance_basic (58.52s)
--- PASS: TestAccAWSLightsailInstance_update (61.50s)
--- PASS: TestAccAWSLightsailInstance_euRegion (63.54s)

@bflad bflad added this to the v2.19.0 milestone Jul 10, 2019
@bflad bflad merged commit ad94171 into hashicorp:master Jul 10, 2019
bflad added a commit that referenced this pull request Jul 10, 2019
@blckct
Copy link
Contributor Author

blckct commented Jul 10, 2019

Thanks.

@blckct blckct deleted the add_lightsail_instance_tags branch July 10, 2019 07:02
@bflad
Copy link
Contributor

bflad commented Jul 11, 2019

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

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Nov 2, 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 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/lightsail Issues and PRs that pertain to the lightsail service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants