-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Conversation
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.
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() { |
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.
The resource Create
function does not call Update
, so the d.IsNewResource()
check is extraneous. 👍
if d.HasChange("tags") && !d.IsNewResource() { | |
if d.HasChange("tags") { |
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.
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"), |
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.
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!
resource.TestCheckResourceAttr("aws_lightsail_instance.lightsail_instance_test", "tags.%", "1"), | |
resource.TestCheckResourceAttr("aws_lightsail_instance.lightsail_instance_test", "tags.%", "0"), |
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.
Done.
|
||
func testAccAWSLightsailInstanceConfig_updated(lightsailName string) string { | ||
return fmt.Sprintf(` | ||
provider "aws" { |
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.
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
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 think I've done it correctly this time but please check.
b535616
to
ad94171
Compare
I've commited the code review changes and then squashed everything into one commit. Thanks for reviewing this. |
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 looks great, thanks @blckct! 🚀
--- PASS: TestAccAWSLightsailInstance_disapear (46.38s)
--- PASS: TestAccAWSLightsailInstance_basic (58.52s)
--- PASS: TestAccAWSLightsailInstance_update (61.50s)
--- PASS: TestAccAWSLightsailInstance_euRegion (63.54s)
Thanks. |
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! |
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! |
Community Note
Add tags support for Lightsail instances.
Release note for CHANGELOG:
Output from acceptance testing: