@@ -68,6 +68,48 @@ func TestAccAutomationDscConfiguration_complete(t *testing.T) {
6868 })
6969}
7070
71+ func TestAccAutomationDscConfiguration_update (t * testing.T ) {
72+ data := acceptance .BuildTestData (t , "azurerm_automation_dsc_configuration" , "test" )
73+ r := AutomationDscConfigurationResource {}
74+ data .ResourceTest (t , r , []acceptance.TestStep {
75+ {
76+ Config : r .basic (data ),
77+ Check : acceptance .ComposeTestCheckFunc (
78+ check .That (data .ResourceName ).ExistsInAzure (r ),
79+ check .That (data .ResourceName ).Key ("description" ).HasValue ("test" ),
80+ check .That (data .ResourceName ).Key ("content_embedded" ).HasValue ("configuration acctest {}" ),
81+ check .That (data .ResourceName ).Key ("tags.%" ).HasValue ("1" ),
82+ check .That (data .ResourceName ).Key ("tags.ENV" ).HasValue ("prod" ),
83+ ),
84+ },
85+ data .ImportStep (),
86+ {
87+ Config : r .updated (data ),
88+ Check : acceptance .ComposeTestCheckFunc (
89+ check .That (data .ResourceName ).ExistsInAzure (r ),
90+ check .That (data .ResourceName ).Key ("description" ).HasValue ("test - updated" ),
91+ check .That (data .ResourceName ).Key ("content_embedded" ).HasValue ("configuration acctest_updated {}" ),
92+ check .That (data .ResourceName ).Key ("log_verbose" ).HasValue ("true" ),
93+ check .That (data .ResourceName ).Key ("tags.%" ).HasValue ("2" ),
94+ check .That (data .ResourceName ).Key ("tags.ENV" ).HasValue ("stage" ),
95+ check .That (data .ResourceName ).Key ("tags.UPDATE" ).HasValue ("true" ),
96+ ),
97+ },
98+ data .ImportStep (),
99+ {
100+ Config : r .basic (data ),
101+ Check : acceptance .ComposeTestCheckFunc (
102+ check .That (data .ResourceName ).ExistsInAzure (r ),
103+ check .That (data .ResourceName ).Key ("description" ).HasValue ("test" ),
104+ check .That (data .ResourceName ).Key ("content_embedded" ).HasValue ("configuration acctest {}" ),
105+ check .That (data .ResourceName ).Key ("tags.%" ).HasValue ("1" ),
106+ check .That (data .ResourceName ).Key ("tags.ENV" ).HasValue ("prod" ),
107+ ),
108+ },
109+ data .ImportStep (),
110+ })
111+ }
112+
71113func (t AutomationDscConfigurationResource ) Exists (ctx context.Context , clients * clients.Client , state * pluginsdk.InstanceState ) (* bool , error ) {
72114 id , err := dscconfiguration .ParseConfigurationID (state .ID )
73115 if err != nil {
@@ -163,3 +205,38 @@ resource "azurerm_automation_dsc_configuration" "test" {
163205}
164206` , data .RandomInteger , data .Locations .Primary , data .RandomInteger )
165207}
208+
209+ func (AutomationDscConfigurationResource ) updated (data acceptance.TestData ) string {
210+ return fmt .Sprintf (`
211+ provider "azurerm" {
212+ features {}
213+ }
214+
215+ resource "azurerm_resource_group" "test" {
216+ name = "acctestRG-auto-%d"
217+ location = "%s"
218+ }
219+
220+ resource "azurerm_automation_account" "test" {
221+ name = "acctest-%d"
222+ location = azurerm_resource_group.test.location
223+ resource_group_name = azurerm_resource_group.test.name
224+ sku_name = "Basic"
225+ }
226+
227+ resource "azurerm_automation_dsc_configuration" "test" {
228+ name = "acctest"
229+ resource_group_name = azurerm_resource_group.test.name
230+ automation_account_name = azurerm_automation_account.test.name
231+ location = azurerm_resource_group.test.location
232+ content_embedded = "configuration acctest_updated {}"
233+ description = "test - updated"
234+ log_verbose = true
235+
236+ tags = {
237+ ENV = "stage"
238+ UPDATE = "true"
239+ }
240+ }
241+ ` , data .RandomInteger , data .Locations .Primary , data .RandomInteger )
242+ }
0 commit comments