Skip to content

Commit

Permalink
azurerm_eventgrid_domain - Export primary_access_key and `seconda…
Browse files Browse the repository at this point in the history
…ry_access_key` (#4876)
  • Loading branch information
hbuckle authored and mbfrahry committed Nov 15, 2019
1 parent 346ba91 commit b6f0fa5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
19 changes: 19 additions & 0 deletions azurerm/resource_arm_eventgrid_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ func resourceArmEventGridDomain() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"primary_access_key": {
Type: schema.TypeString,
Computed: true,
Sensitive: true,
},

"secondary_access_key": {
Type: schema.TypeString,
Computed: true,
Sensitive: true,
},
},
}
}
Expand Down Expand Up @@ -244,6 +256,13 @@ func resourceArmEventGridDomainRead(d *schema.ResourceData, meta interface{}) er
}
}

keys, err := client.ListSharedAccessKeys(ctx, resourceGroup, name)
if err != nil {
return fmt.Errorf("Error retrieving Shared Access Keys for EventGrid Domain %q: %+v", name, err)
}
d.Set("primary_access_key", keys.Key1)
d.Set("secondary_access_key", keys.Key2)

return tags.FlattenAndSet(d, resp.Tags)
}

Expand Down
2 changes: 2 additions & 0 deletions azurerm/resource_arm_eventgrid_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func TestAccAzureRMEventGridDomain_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMEventGridDomainExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "endpoint"),
resource.TestCheckResourceAttrSet(resourceName, "primary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_access_key"),
),
},
{
Expand Down
6 changes: 5 additions & 1 deletion website/docs/r/eventgrid_domain.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ The following attributes are exported:

* `endpoint` - The Endpoint associated with the EventGrid Domain.

* `primary_access_key` - The Primary Shared Access Key associated with the EventGrid Domain.

* `secondary_access_key` - The Secondary Shared Access Key associated with the EventGrid Domain.

## Import

EventGrid Domain's can be imported using the `resource id`, e.g.
EventGrid Domains can be imported using the `resource id`, e.g.

```shell
terraform import azurerm_eventgrid_domain.domain1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.EventGrid/domains/domain1
Expand Down

0 comments on commit b6f0fa5

Please sign in to comment.