Skip to content

Commit

Permalink
review fixes and amendments
Browse files Browse the repository at this point in the history
  • Loading branch information
jackofallops committed Jun 9, 2020
1 parent ecf0e9a commit 3af1f28
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 5 deletions.
4 changes: 2 additions & 2 deletions azurerm/internal/services/blueprints/blueprint.go
Expand Up @@ -67,7 +67,7 @@ func blueprintAssignmentCreateStateRefreshFunc(ctx context.Context, client *blue
return nil, "", fmt.Errorf("unable to retrieve Blueprint Assignment %q (Scope %q): %+v", name, scope, err)
}
if resp.ProvisioningState == blueprint.Failed {
return resp, string(resp.ProvisioningState), err
return resp, string(resp.ProvisioningState), fmt.Errorf("Blueprint Assignment provisioning entered a Failed state.")
}

return resp, string(resp.ProvisioningState), nil
Expand Down Expand Up @@ -132,7 +132,7 @@ func expandArmBlueprintAssignmentResourceGroups(input string) map[string]*bluepr
}

func expandArmBlueprintAssignmentIdentity(input []interface{}) (*blueprint.ManagedServiceIdentity, error) {
if len(input) == 0 {
if len(input) == 0 || input[0] == nil {
return nil, fmt.Errorf("Managed Service Identity was empty")
}

Expand Down
Expand Up @@ -208,6 +208,10 @@ func resourceArmBlueprintAssignmentCreateUpdate(d *schema.ResourceData, meta int
return fmt.Errorf("failed waiting for Blueprint Assignment %q (Scope %q): %+v", name, targetScope, err)
}

if resp.ID == nil || *resp.ID == "" {
return fmt.Errorf("could not read ID from Blueprint Assignment %q on scope %q", name, targetScope)
}

d.SetId(*resp.ID)

return resourceArmBlueprintAssignmentRead(d, meta)
Expand Down Expand Up @@ -258,15 +262,15 @@ func resourceArmBlueprintAssignmentRead(d *schema.ResourceData, meta interface{}
d.Set("version_id", resp.AssignmentProperties.BlueprintID)
}

if resp.Parameters != nil {
if resp.AssignmentProperties.Parameters != nil {
params, err := flattenArmBlueprintAssignmentParameters(resp.Parameters)
if err != nil {
return err
}
d.Set("parameter_values", params)
}

if resp.ResourceGroups != nil {
if resp.AssignmentProperties.ResourceGroups != nil {
resourceGroups, err := flattenArmBlueprintAssignmentResourceGroups(resp.ResourceGroups)
if err != nil {
return err
Expand Down
Expand Up @@ -32,6 +32,32 @@ func TestAccBlueprintAssignment_basic(t *testing.T) {
})
}

func TestAccBlueprintAssignment_basicUpdated(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_blueprint_assignment", "test")

resource.Test(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMBlueprintAssignmentDestroy,
Steps: []resource.TestStep{
{
Config: testAccBlueprintAssignment_basic(data, "testAcc_basicSubscription", "v0.1_testAcc"),
Check: resource.ComposeTestCheckFunc(
testCheckBlueprintAssignmentExists(data.ResourceName),
),
},
data.ImportStep(),
{
Config: testAccBlueprintAssignment_basic(data, "testAcc_basicSubscription", "v0.2_testAcc"),
Check: resource.ComposeTestCheckFunc(
testCheckBlueprintAssignmentExists(data.ResourceName),
),
},
data.ImportStep(),
},
})
}

func TestAccBlueprintAssignment_requiresImport(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_blueprint_assignment", "test")

Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/blueprint_definition.html.markdown
Expand Up @@ -10,6 +10,8 @@ description: |-

Use this data source to access information about an existing Azure Blueprint Definition

~> **NOTE:** Azure Blueprints are in Preview and potentially subject to breaking change without notice.

## Example Usage

```hcl
Expand Down
5 changes: 4 additions & 1 deletion website/docs/d/blueprint_published_version.html.markdown
Expand Up @@ -10,13 +10,16 @@ description: |-

Use this data source to access information about an existing Azure Blueprint Published Version

~> **NOTE:** Azure Blueprints are in Preview and potentially subject to breaking change without notice.


## Example Usage
```hcl
data "azurerm_subscription" "current" {}
data "azurerm_blueprint_published_version" "test" {
scope_id = data.azurerm_subscription.current.id
blueprint_name = "exampleMGBluePrint"
blueprint_name = "exampleBluePrint"
version = "dev_v2.3"
}
```
Expand Down
21 changes: 21 additions & 0 deletions website/docs/r/blueprint_assignment.html.markdown
Expand Up @@ -10,6 +10,10 @@ description: |-

Manages a Blueprint Assignment resource

~> **NOTE:** Azure Blueprints are in Preview and potentially subject to breaking change without notice.

~> **NOTE:** Azure Blueprint Assignments can only be applied to Subscriptions. Assignments to Management Groups is not currently supported by the service or by Terraform.

## Example Usage
```hcl
provider "azurerm" {
Expand Down Expand Up @@ -142,3 +146,20 @@ An `identity` block supports the following Arguments
* `display_name` - The display name of the blueprint

* `blueprint_name` - The name of the blueprint assigned

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:

* `create` - (Defaults to 30 minutes) Used when creating the Blueprint Assignment.
* `update` - (Defaults to 30 minutes) Used when updating the Blueprint Assignment.
* `read` - (Defaults to 5 minutes) Used when retrieving the Blueprint Assignment.
* `delete` - (Defaults to 5 minutes) Used when deleting the Blueprint Assignment.

## Import

Azure Blueprint Assignments can be imported using the `resource id`, e.g.

```shell
terraform import azurerm_blueprint_assignment.example "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Blueprint/blueprintAssignments/assignSimpleBlueprint"
```

0 comments on commit 3af1f28

Please sign in to comment.