Skip to content

Commit

Permalink
all properties should be ForceNew since resources do not support Update
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer committed May 15, 2024
1 parent 65131b2 commit effd5c5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func (PimActiveRoleAssignmentResource) Arguments() map[string]*pluginsdk.Schema
"justification": {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Description: "The justification for this role assignment",
},
Expand Down Expand Up @@ -185,14 +186,16 @@ func (PimActiveRoleAssignmentResource) Arguments() map[string]*pluginsdk.Schema
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"number": {
Optional: true,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Description: "User-supplied ticket number to be included with the request",
},

"system": {
Optional: true,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Description: "User-supplied ticket system name to be included with the request",
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,6 @@ func TestAccPimActiveRoleAssignment_expirationByDurationDaysConfig(t *testing.T)
})
}

func TestAccPimActiveRoleAssignment_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_pim_active_role_assignment", "test")
r := PimActiveRoleAssignmentResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.update1(),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("scope").Exists(),
),
},
data.ImportStep("schedule.0.start_date_time"),
{
Config: r.update2(),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("scope").Exists(),
),
},
data.ImportStep("schedule.0.start_date_time"),
})
}

func TestAccPimActiveRoleAssignment_pending(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_pim_active_role_assignment", "test")
r := PimActiveRoleAssignmentResource{}
Expand Down Expand Up @@ -372,74 +348,6 @@ resource "azurerm_pim_active_role_assignment" "test" {
`
}

func (PimActiveRoleAssignmentResource) update1() string {
return `
data "azurerm_subscription" "primary" {}
data "azurerm_client_config" "test" {}
data "azurerm_role_definition" "test" {
name = "Billing Reader"
}
resource "time_static" "test" {}
resource "azurerm_pim_active_role_assignment" "test" {
scope = data.azurerm_subscription.primary.id
role_definition_id = "${data.azurerm_subscription.primary.id}${data.azurerm_role_definition.test.id}"
principal_id = data.azurerm_client_config.test.object_id
schedule {
start_date_time = time_static.test.rfc3339
expiration {
duration_hours = 8
}
}
justification = "Expiration Duration Set"
ticket {
number = "1"
system = "example ticket system"
}
}
`
}

func (PimActiveRoleAssignmentResource) update2() string {
return `
data "azurerm_subscription" "primary" {}
data "azurerm_client_config" "test" {}
data "azurerm_role_definition" "test" {
name = "Billing Reader"
}
resource "time_static" "test" {}
resource "azurerm_pim_active_role_assignment" "test" {
scope = data.azurerm_subscription.primary.id
role_definition_id = "${data.azurerm_subscription.primary.id}${data.azurerm_role_definition.test.id}"
principal_id = data.azurerm_client_config.test.object_id
schedule {
start_date_time = time_static.test.rfc3339
expiration {
duration_hours = 8
}
}
justification = "Expiration Duration Set"
ticket {
number = "2"
system = "example ticket system"
}
}
`
}

func (PimActiveRoleAssignmentResource) pending() string {
return `
data "azurerm_subscription" "primary" {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (PimEligibleRoleAssignmentResource) Arguments() map[string]*pluginsdk.Schem
"justification": {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Description: "The justification for this eligible role assignment",
},
Expand Down Expand Up @@ -136,10 +137,10 @@ func (PimEligibleRoleAssignmentResource) Arguments() map[string]*pluginsdk.Schem
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"duration_days": {
Type: pluginsdk.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
Type: pluginsdk.TypeInt,
ConflictsWith: []string{
"schedule.0.expiration.0.duration_hours",
"schedule.0.expiration.0.end_date_time",
Expand All @@ -160,10 +161,10 @@ func (PimEligibleRoleAssignmentResource) Arguments() map[string]*pluginsdk.Schem
},

"end_date_time": {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Type: pluginsdk.TypeString,
ConflictsWith: []string{
"schedule.0.expiration.0.duration_days",
"schedule.0.expiration.0.duration_hours",
Expand All @@ -186,14 +187,16 @@ func (PimEligibleRoleAssignmentResource) Arguments() map[string]*pluginsdk.Schem
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"number": {
Optional: true,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Description: "User-supplied ticket number to be included with the request",
},

"system": {
Optional: true,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Description: "User-supplied ticket system name to be included with the request",
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,6 @@ func TestAccPimEligibleRoleAssignment_expirationByDurationDaysConfig(t *testing.
})
}

func TestAccPimEligibleRoleAssignment_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_pim_eligible_role_assignment", "test")
r := PimEligibleRoleAssignmentResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.update1(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("scope").Exists(),
),
},
data.ImportStep("schedule.0.start_date_time"),
{
Config: r.update2(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("scope").Exists(),
),
},
data.ImportStep("schedule.0.start_date_time"),
})
}

func TestAccPimEligibleRoleAssignment_pending(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_pim_eligible_role_assignment", "test")
r := PimEligibleRoleAssignmentResource{}
Expand Down Expand Up @@ -422,78 +398,6 @@ resource "azurerm_pim_eligible_role_assignment" "test" {
`, aadGroup(data))
}

func (PimEligibleRoleAssignmentResource) update1(data acceptance.TestData) string {
return fmt.Sprintf(`
data "azurerm_subscription" "primary" {}
data "azurerm_client_config" "test" {}
data "azurerm_role_definition" "test" {
name = "Billing Reader"
}
%s
resource "time_static" "test" {}
resource "azurerm_pim_eligible_role_assignment" "test" {
scope = data.azurerm_subscription.primary.id
role_definition_id = "${data.azurerm_subscription.primary.id}${data.azurerm_role_definition.test.id}"
principal_id = azuread_user.test.object_id
schedule {
start_date_time = time_static.test.rfc3339
expiration {
duration_hours = 8
}
}
justification = "Expiration Duration Set"
ticket {
number = "1"
system = "example ticket system"
}
}
`, aadGroup(data))
}

func (PimEligibleRoleAssignmentResource) update2(data acceptance.TestData) string {
return fmt.Sprintf(`
data "azurerm_subscription" "primary" {}
data "azurerm_client_config" "test" {}
data "azurerm_role_definition" "test" {
name = "Billing Reader"
}
%s
resource "time_static" "test" {}
resource "azurerm_pim_eligible_role_assignment" "test" {
scope = data.azurerm_subscription.primary.id
role_definition_id = "${data.azurerm_subscription.primary.id}${data.azurerm_role_definition.test.id}"
principal_id = azuread_user.test.object_id
schedule {
start_date_time = time_static.test.rfc3339
expiration {
duration_hours = 8
}
}
justification = "Expiration Duration Set"
ticket {
number = "2"
system = "example ticket system"
}
}
`, aadGroup(data))
}

func (PimEligibleRoleAssignmentResource) pending(data acceptance.TestData) string {
return fmt.Sprintf(`
data "azurerm_subscription" "primary" {}
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/pim_active_role_assignment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ A `schedule` block supports the following:

A `ticket` block supports the following:

* `number` - (Optional) User-supplied ticket number to be included with the request.
* `number` - (Optional) User-supplied ticket number to be included with the request. Changing this forces a new resource to be created.

* `system` - (Optional) User-supplied ticket system name to be included with the request.
* `system` - (Optional) User-supplied ticket system name to be included with the request. Changing this forces a new resource to be created.

## Attributes Reference

Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/pim_eligible_role_assignment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ A `schedule` block supports the following:

A `ticket` block supports the following:

* `number` - (Optional) User-supplied ticket number to be included with the request.
* `number` - (Optional) User-supplied ticket number to be included with the request. Changing this forces a new resource to be created.

* `system` - (Optional) User-supplied ticket system name to be included with the request.
* `system` - (Optional) User-supplied ticket system name to be included with the request. Changing this forces a new resource to be created.

## Attributes Reference

Expand Down

0 comments on commit effd5c5

Please sign in to comment.