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

Include access keys and connection strings in azurerm_signalr_service #2655

Merged
merged 4 commits into from
Jan 12, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
34 changes: 34 additions & 0 deletions azurerm/resource_arm_signalr_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,30 @@ func resourceArmSignalRService() *schema.Resource {
Computed: true,
},

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

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

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

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

"tags": tagsSchema(),
},
}
Expand Down Expand Up @@ -143,6 +167,11 @@ func resourceArmSignalRServiceRead(d *schema.ResourceData, meta interface{}) err
return fmt.Errorf("Error getting SignalR %q (Resource Group %q): %+v", name, resourceGroup, err)
}

keys, err := client.ListKeys(ctx, resourceGroup, name)
if err != nil {
return fmt.Errorf("Error getting keys of SignalR %q (Resource Group %q): %+v", name, resourceGroup, err)
}

d.Set("name", name)
d.Set("resource_group_name", resourceGroup)
if location := resp.Location; location != nil {
Expand All @@ -160,6 +189,11 @@ func resourceArmSignalRServiceRead(d *schema.ResourceData, meta interface{}) err
d.Set("server_port", properties.ServerPort)
}

d.Set("primary_access_key", keys.PrimaryKey)
d.Set("primary_connection_string", keys.PrimaryConnectionString)
d.Set("secondary_access_key", keys.SecondaryKey)
d.Set("secondary_connection_string", keys.SecondaryConnectionString)

flattenAndSetTags(d, resp.Tags)

return nil
Expand Down
48 changes: 48 additions & 0 deletions azurerm/resource_arm_signalr_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func TestAccAzureRMSignalRService_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttrSet(resourceName, "public_port"),
resource.TestCheckResourceAttrSet(resourceName, "server_port"),
resource.TestCheckResourceAttrSet(resourceName, "primary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"),
),
},
{
Expand Down Expand Up @@ -61,6 +65,10 @@ func TestAccAzureRMSignalRService_standard(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttrSet(resourceName, "public_port"),
resource.TestCheckResourceAttrSet(resourceName, "server_port"),
resource.TestCheckResourceAttrSet(resourceName, "primary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"),
),
},
{
Expand Down Expand Up @@ -92,6 +100,10 @@ func TestAccAzureRMSignalRService_standardWithCap2(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttrSet(resourceName, "public_port"),
resource.TestCheckResourceAttrSet(resourceName, "server_port"),
resource.TestCheckResourceAttrSet(resourceName, "primary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"),
),
},
{
Expand Down Expand Up @@ -125,6 +137,10 @@ func TestAccAzureRMSignalRService_skuUpdate(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttrSet(resourceName, "public_port"),
resource.TestCheckResourceAttrSet(resourceName, "server_port"),
resource.TestCheckResourceAttrSet(resourceName, "primary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"),
),
},
{
Expand All @@ -137,6 +153,10 @@ func TestAccAzureRMSignalRService_skuUpdate(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttrSet(resourceName, "public_port"),
resource.TestCheckResourceAttrSet(resourceName, "server_port"),
resource.TestCheckResourceAttrSet(resourceName, "primary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"),
),
},
{
Expand All @@ -149,6 +169,10 @@ func TestAccAzureRMSignalRService_skuUpdate(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttrSet(resourceName, "public_port"),
resource.TestCheckResourceAttrSet(resourceName, "server_port"),
resource.TestCheckResourceAttrSet(resourceName, "primary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"),
),
},
},
Expand Down Expand Up @@ -177,6 +201,10 @@ func TestAccAzureRMSignalRService_capacityUpdate(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttrSet(resourceName, "public_port"),
resource.TestCheckResourceAttrSet(resourceName, "server_port"),
resource.TestCheckResourceAttrSet(resourceName, "primary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"),
),
},
{
Expand All @@ -189,6 +217,10 @@ func TestAccAzureRMSignalRService_capacityUpdate(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttrSet(resourceName, "public_port"),
resource.TestCheckResourceAttrSet(resourceName, "server_port"),
resource.TestCheckResourceAttrSet(resourceName, "primary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"),
),
},
{
Expand All @@ -201,6 +233,10 @@ func TestAccAzureRMSignalRService_capacityUpdate(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttrSet(resourceName, "public_port"),
resource.TestCheckResourceAttrSet(resourceName, "server_port"),
resource.TestCheckResourceAttrSet(resourceName, "primary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"),
),
},
},
Expand Down Expand Up @@ -229,6 +265,10 @@ func TestAccAzureRMSignalRService_skuAndCapacityUpdate(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttrSet(resourceName, "public_port"),
resource.TestCheckResourceAttrSet(resourceName, "server_port"),
resource.TestCheckResourceAttrSet(resourceName, "primary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"),
),
},
{
Expand All @@ -241,6 +281,10 @@ func TestAccAzureRMSignalRService_skuAndCapacityUpdate(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttrSet(resourceName, "public_port"),
resource.TestCheckResourceAttrSet(resourceName, "server_port"),
resource.TestCheckResourceAttrSet(resourceName, "primary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"),
),
},
{
Expand All @@ -253,6 +297,10 @@ func TestAccAzureRMSignalRService_skuAndCapacityUpdate(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttrSet(resourceName, "public_port"),
resource.TestCheckResourceAttrSet(resourceName, "server_port"),
resource.TestCheckResourceAttrSet(resourceName, "primary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_access_key"),
resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"),
),
},
},
Expand Down
38 changes: 23 additions & 15 deletions website/docs/r/signalr_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ Manages an Azure SignalR service.
## Example Usage

```hcl
resource "azurerm_resource_group" "example" {
name = "terraform-signalr"
location = "West US"
}

resource "azurerm_signalr_service" "example" {
name = "tfex-signalr"
location = "${azurerm_resource_group.example.location}"
resource_group_name = "${azurerm_resource_group.example.name}"

sku {
name = "Free_F1"
capacity = 1
}
}
resource "azurerm_resource_group" "example" {
name = "terraform-signalr"
location = "West US"
}
resource "azurerm_signalr_service" "example" {
name = "tfex-signalr"
location = "${azurerm_resource_group.example.location}"
resource_group_name = "${azurerm_resource_group.example.name}"
sku {
name = "Free_F1"
capacity = 1
}
}
```

## Argument Reference
Expand Down Expand Up @@ -66,6 +66,14 @@ The following attributes are exported:

* `server_port` - The publicly accessible port of the SignalR service which is designed for customer server side use.

* `primary_access_key` - The primary access key for the SignalR service.

* `primary_connection_string` - The primary connection string for the SignalR service.

* `secondary_access_key` - The secondary access key for the SignalR service.

* `secondary_connection_string` - The secondary connection string for the SignalR service.

## Import

SignalR services can be imported using the `resource id`, e.g.
Expand Down