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

Enhancement: azurerm_private_endpoint expose private_ip_address as computed attribute #5838

Merged
merged 2 commits into from
Feb 26, 2020

Conversation

njuCZ
Copy link
Contributor

@njuCZ njuCZ commented Feb 21, 2020

fixes #5622
fixes #5208

add private_ip_address just like data source azurerm_private_endpoint_connection.

Because azurerm_private_link_endpoint use the same flatten function, So I set this field outside this flatten function

@WodansSon WodansSon self-assigned this Feb 25, 2020
@WodansSon WodansSon added this to the v2.1.0 milestone Feb 25, 2020
@WodansSon WodansSon changed the title add private_ip_address for azurerm_private_endpoint Enhancement: azurerm_private_endpoint expose private_ip_address as computed attribute Feb 25, 2020
Copy link
Collaborator

@WodansSon WodansSon left a comment

Choose a reason for hiding this comment

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

@njuCZ , thanks for PR... I had a look while this mostly LGTM the is one minor change I would like to see made. Thanks again for the PR! 🚀

Comment on lines +211 to +214
for _, item := range flattenedConnection {
v := item.(map[string]interface{})
v["private_ip_address"] = privateIpAddress
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you need to loop over the returned slice you just need to append the value to it if the privateIpAddress is not empty, something like the below... WDYT?

if privateIpAddress != "" {
	privateIp := make(map[string]interface{})
	privateIp["private_ip_address"] = privateIpAddress 
	flattenedConnection = append(flattenedConnection, privateIp)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@WodansSon the flattenedConnection is a list of map, append it with another map will cause flattenedConnection has two maps, not a merged map.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@njuCZ I got the iteration mixed up in my head... you're right... this is fine.

Copy link
Collaborator

@WodansSon WodansSon left a comment

Choose a reason for hiding this comment

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

Thanks @njuCZ this LGTM! 🚀

Comment on lines +211 to +214
for _, item := range flattenedConnection {
v := item.(map[string]interface{})
v["private_ip_address"] = privateIpAddress
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@njuCZ I got the iteration mixed up in my head... you're right... this is fine.

@WodansSon
Copy link
Collaborator

image

@WodansSon WodansSon merged commit 7ca24f0 into hashicorp:master Feb 26, 2020
WodansSon added a commit that referenced this pull request Feb 26, 2020
@ghost
Copy link

ghost commented Mar 11, 2020

This has been released in version 2.1.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.1.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Mar 27, 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. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.