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

azurerm_api_management: Deploy APIM in a vnet #5494

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -62,6 +62,14 @@ func resourceArmApiManagementService() *schema.Resource {
},
},

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we put these new values into a virtual_network block?

"private_ip_addresses": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we put computed values at the end of the block?

Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},

"publisher_name": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -460,6 +468,21 @@ func resourceArmApiManagementService() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"vnet_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"External",
"Internal",
"None",
}, false),
},

"subnet_id": {
Type: schema.TypeString,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -514,6 +537,12 @@ func resourceArmApiManagementServiceCreateUpdate(d *schema.ResourceData, meta in
CustomProperties: customProperties,
Certificates: certificates,
HostnameConfigurations: hostnameConfigurations,
VirtualNetworkType: virtualNetworkTypeStringToType(utils.String(d.Get("vnet_type").(string))),
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should be able to go

Suggested change
VirtualNetworkType: virtualNetworkTypeStringToType(utils.String(d.Get("vnet_type").(string))),
VirtualNetworkType: apimanagement.VirtualNetworkType(d.Get("vnet_type").(string))),

VirtualNetworkConfiguration: &apimanagement.VirtualNetworkConfiguration{
Vnetid: utils.String(""),
Subnetname: utils.String(""),
Comment on lines +542 to +543
Copy link
Collaborator

Choose a reason for hiding this comment

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

COuld we also support these two values?

SubnetResourceID: utils.String(d.Get("subnet_id").(string)),
},
},
Tags: tags.Expand(t),
Sku: sku,
Expand Down Expand Up @@ -657,6 +686,7 @@ func resourceArmApiManagementServiceRead(d *schema.ResourceData, meta interface{
d.Set("management_api_url", props.ManagementAPIURL)
d.Set("scm_url", props.ScmURL)
d.Set("public_ip_addresses", props.PublicIPAddresses)
d.Set("private_ip_addresses", props.PrivateIPAddresses)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should we reading in the other new values here too


if err := d.Set("security", flattenApiManagementCustomProperties(props.CustomProperties)); err != nil {
return fmt.Errorf("Error setting `security`: %+v", err)
Expand Down Expand Up @@ -1366,3 +1396,15 @@ func flattenApiManagementPolicies(d *schema.ResourceData, input apimanagement.Po

return []interface{}{output}
}

func virtualNetworkTypeStringToType(s *string) apimanagement.VirtualNetworkType {
switch *s {
case "External":
return apimanagement.VirtualNetworkTypeExternal
case "Internal":
return apimanagement.VirtualNetworkTypeInternal
case "None":
return apimanagement.VirtualNetworkTypeNone
}
return apimanagement.VirtualNetworkTypeNone
}