diff --git a/azurerm/internal/services/blueprints/blueprint.go b/azurerm/internal/services/blueprints/blueprint.go index f060cbf9ece9..64ffaddcdbd1 100644 --- a/azurerm/internal/services/blueprints/blueprint.go +++ b/azurerm/internal/services/blueprints/blueprint.go @@ -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 @@ -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") } diff --git a/azurerm/internal/services/blueprints/blueprint_assignment_resource.go b/azurerm/internal/services/blueprints/blueprint_assignment_resource.go index 8f69be7d96a0..39eede932570 100644 --- a/azurerm/internal/services/blueprints/blueprint_assignment_resource.go +++ b/azurerm/internal/services/blueprints/blueprint_assignment_resource.go @@ -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) @@ -258,7 +262,7 @@ 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 @@ -266,7 +270,7 @@ func resourceArmBlueprintAssignmentRead(d *schema.ResourceData, meta interface{} d.Set("parameter_values", params) } - if resp.ResourceGroups != nil { + if resp.AssignmentProperties.ResourceGroups != nil { resourceGroups, err := flattenArmBlueprintAssignmentResourceGroups(resp.ResourceGroups) if err != nil { return err diff --git a/azurerm/internal/services/blueprints/tests/blueprint_assignment_resource_test.go b/azurerm/internal/services/blueprints/tests/blueprint_assignment_resource_test.go index 5f7ed1ce18fd..1a21c21f2d51 100644 --- a/azurerm/internal/services/blueprints/tests/blueprint_assignment_resource_test.go +++ b/azurerm/internal/services/blueprints/tests/blueprint_assignment_resource_test.go @@ -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") diff --git a/website/docs/d/blueprint_definition.html.markdown b/website/docs/d/blueprint_definition.html.markdown index 537699ebae82..e876dc795aa2 100644 --- a/website/docs/d/blueprint_definition.html.markdown +++ b/website/docs/d/blueprint_definition.html.markdown @@ -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 diff --git a/website/docs/d/blueprint_published_version.html.markdown b/website/docs/d/blueprint_published_version.html.markdown index aab0cbb9fd3f..7c53ae5fad65 100644 --- a/website/docs/d/blueprint_published_version.html.markdown +++ b/website/docs/d/blueprint_published_version.html.markdown @@ -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" } ``` diff --git a/website/docs/r/blueprint_assignment.html.markdown b/website/docs/r/blueprint_assignment.html.markdown index 1ce2e83923b9..f2046a0c73ef 100644 --- a/website/docs/r/blueprint_assignment.html.markdown +++ b/website/docs/r/blueprint_assignment.html.markdown @@ -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" { @@ -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" +``` \ No newline at end of file