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_eventgrid_domain - Export primary_access_key and secondary_access_key #4876

Merged
merged 2 commits into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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