New Resource: azurerm_nat_gateway_public_ip_prefix_v6_association#31325
New Resource: azurerm_nat_gateway_public_ip_prefix_v6_association#31325neil-yechenwei wants to merge 21 commits intohashicorp:mainfrom
azurerm_nat_gateway_public_ip_prefix_v6_association#31325Conversation
…ort for new SKU StandardV2
|
Thanks @neil-yechenwei , LGTM! |
| if props := model.Properties; props != nil { | ||
| publicIpPrefixesV6 := make([]natgateways.SubResource, 0) | ||
|
|
||
| if publicIPPrefixesV6 := props.PublicIPPrefixesV6; publicIPPrefixesV6 != nil { |
There was a problem hiding this comment.
publicIPPrefixesV6 is re-assigned here in the if-condition.
| if props := model.Properties; props != nil { | ||
| publicIpPrefixesV6 := make([]natgateways.SubResource, 0) | ||
|
|
||
| if publicIPPrefixesV6 := props.PublicIPPrefixesV6; publicIPPrefixesV6 != nil { |
|
|
||
| type NatGatewayPublicIpPrefixV6AssociationResource struct{} | ||
|
|
||
| func TestAccNatGatewayPublicIpPrefixV6Association_basic(t *testing.T) { |
There was a problem hiding this comment.
Add a test to verify multiple associations
|
@ms-henglu , thanks for the comments. I updated PR. Please take another look. Below is the latest test result. |
…m into natgatewaypublicipv6prefixassociation
| natGateway.Model.Properties.PublicIPPrefixesV6 = pointer.To(publicIpPrefixesV6) | ||
|
|
||
| if err := client.CreateOrUpdateThenPoll(ctx, *id.First, *natGateway.Model); err != nil { | ||
| return fmt.Errorf("removing association between %s and %s: %+v", *id.First, *id.Second, err) |
There was a problem hiding this comment.
| return fmt.Errorf("removing association between %s and %s: %+v", *id.First, *id.Second, err) | |
| return fmt.Errorf("deleting %s: %+v", id, err) |
|
|
||
| var state NATGatewayPublicIpPrefixV6AssociationModel | ||
| if err := metadata.Decode(&state); err != nil { | ||
| return err |
There was a problem hiding this comment.
| return err | |
| return fmt.Errorf("decoding: %+v", err) |
| A NAT Gateway and IPv6 Public IP Prefix association can be imported using the `resource id`, e.g. | ||
|
|
||
| ```shell | ||
| terraform import azurerm_nat_gateway_public_ip_prefix_v6_association.example "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Network/natGateways/natGateway1|/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Network/publicIPPrefixes/publicIPPrefix1" |
There was a problem hiding this comment.
| terraform import azurerm_nat_gateway_public_ip_prefix_v6_association.example "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Network/natGateways/natGateway1|/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Network/publicIPPrefixes/publicIPPrefix1" | |
| terraform import azurerm_nat_gateway_public_ip_prefix_v6_association.example "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/natGateways/gateway1|/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/publicIPPrefixes/prefix1" |
|
|
||
| In addition to the Arguments listed above - the following Attributes are exported: | ||
|
|
||
| * `id` - The (Terraform specific) ID of the Association between the NAT Gateway and the IPv6 Public IP Prefix. |
There was a problem hiding this comment.
| * `id` - The (Terraform specific) ID of the Association between the NAT Gateway and the IPv6 Public IP Prefix. | |
| * `id` - The ID of the Association between the NAT Gateway and the IPv6 Public IP Prefix. |
| natGateway.Model.Properties.PublicIPPrefixesV6 = pointer.To(publicIpPrefixesV6) | ||
|
|
||
| if err := client.CreateOrUpdateThenPoll(ctx, *natGatewayId, *natGateway.Model); err != nil { | ||
| return fmt.Errorf("updating %s: %+v", *natGatewayId, err) |
There was a problem hiding this comment.
| return fmt.Errorf("updating %s: %+v", *natGatewayId, err) | |
| return fmt.Errorf("creating %s: %+v", id, err) |
|
Hi @ms-zhenhua , thanks for reviewing! I have updated the code, please take another look. |
wuxu92
left a comment
There was a problem hiding this comment.
Thanks for the updates on this PR! could you please have a look and update it to align with comment in #31321 (review) as these two PRs are very similar.
|
Hi @wuxu92 , thanks for reviewing. I have updated the code, please take another look. |
wuxu92
left a comment
There was a problem hiding this comment.
Thanks @teowa The resource looks good now. could you please add the identity support for the new resource with guidance: ./contributing/topics/guide-resource-identity.md . also add identity support for the ipv6 association resource. Thanks!
|
Hi @wuxu92 , The identity framework behind terraform-provider-azurerm/internal/sdk/resource.go Lines 112 to 117 in 6f5f895 |
|
Is being discussed internally with @wuxu92 |
|
superseded by #32195 |

Community Note
Description
This PR is to support new association resource
azurerm_nat_gateway_public_ip_prefix_v6_associationfor new featurepublicIpPrefixesV6. This PR depends on #31197. Once PR 31197 is merged, please don't merge this PR since I will rebase the code.PR Checklist
For example: “
resource_name_here- description of change e.g. adding propertynew_property_name_here”Changes to existing Resource / Data Source
Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_nat_gateway_public_ip_prefix_v6_associationThis is a (please select all that apply):
Related Issue(s)
Fixes # 0000
AI Assistance Disclosure
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the provider.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
Note
If this PR changes meaningfully during the course of review please update the title and description as required.