Skip to content

Commit

Permalink
provider/azurerm: support import of cdn_endpoint, document profile im…
Browse files Browse the repository at this point in the history
…port

TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMCdnEndpoint_import -timeout 120m
=== RUN   TestAccAzureRMCdnEndpoint_importWithTags
--- PASS: TestAccAzureRMCdnEndpoint_importWithTags (207.83s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	207.907s
  • Loading branch information
Peter McAtominey committed Nov 18, 2016
1 parent 02c51cd commit ec35cc3
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
33 changes: 33 additions & 0 deletions builtin/providers/azurerm/import_arm_cdn_endpoint_test.go
@@ -0,0 +1,33 @@
package azurerm

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAzureRMCdnEndpoint_importWithTags(t *testing.T) {
resourceName := "azurerm_cdn_endpoint.test"

ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMCdnEndpoint_withTags, ri, ri, ri)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMCdnEndpointDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},

resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
8 changes: 7 additions & 1 deletion builtin/providers/azurerm/resource_arm_cdn_endpoint.go
Expand Up @@ -18,6 +18,9 @@ func resourceArmCdnEndpoint() *schema.Resource {
Read: resourceArmCdnEndpointRead,
Update: resourceArmCdnEndpointUpdate,
Delete: resourceArmCdnEndpointDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},

Schema: map[string]*schema.Schema{
"name": {
Expand Down Expand Up @@ -234,6 +237,9 @@ func resourceArmCdnEndpointRead(d *schema.ResourceData, meta interface{}) error
}

d.Set("name", resp.Name)
d.Set("resource_group_name", resGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("profile_name", profileName)
d.Set("host_name", resp.Properties.HostName)
d.Set("is_compression_enabled", resp.Properties.IsCompressionEnabled)
d.Set("is_http_allowed", resp.Properties.IsHTTPAllowed)
Expand All @@ -245,7 +251,7 @@ func resourceArmCdnEndpointRead(d *schema.ResourceData, meta interface{}) error
if resp.Properties.OriginPath != nil && *resp.Properties.OriginPath != "" {
d.Set("origin_path", resp.Properties.OriginPath)
}
if resp.Properties.ContentTypesToCompress != nil && len(*resp.Properties.ContentTypesToCompress) > 0 {
if resp.Properties.ContentTypesToCompress != nil {
d.Set("content_types_to_compress", flattenAzureRMCdnEndpointContentTypes(resp.Properties.ContentTypesToCompress))
}
d.Set("origin", flattenAzureRMCdnEndpointOrigin(resp.Properties.Origins))
Expand Down
Expand Up @@ -84,4 +84,12 @@ The `origin` block supports:

The following attributes are exported:

* `id` - The CDN Endpoint ID.
* `id` - The CDN Endpoint ID.

## Import

CDN Endpoints can be imported using the `resource id`, e.g.

```
terraform import azurerm_cdn_endpoint.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Cdn/profiles/myprofile1/endpoints/myendpoint1
```
Expand Up @@ -51,4 +51,12 @@ The following arguments are supported:

The following attributes are exported:

* `id` - The CDN Profile ID.
* `id` - The CDN Profile ID.

## Import

CDN Profiles can be imported using the `resource id`, e.g.

```
terraform import azurerm_cdn_profile.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Cdn/profiles/myprofile1
```

0 comments on commit ec35cc3

Please sign in to comment.