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

Data Source: azurerm_app_service_environment_v3 - fix id processing for Read #12436

Merged
merged 4 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ func (r AppServiceEnvironmentV3DataSource) Attributes() map[string]*pluginsdk.Sc
},
},

"pricing_tier": {
Type: pluginsdk.TypeString,
Computed: true,
},

"location": {
Type: pluginsdk.TypeString,
Computed: true,
},

"tags": tags.SchemaDataSource(),
}
}
Expand All @@ -74,11 +84,15 @@ func (r AppServiceEnvironmentV3DataSource) Read() sdk.ResourceFunc {

Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {
client := metadata.Client.Web.AppServiceEnvironmentsClient
id, err := parse.AppServiceEnvironmentID(metadata.ResourceData.Id())
if err != nil {
return err
subscriptionId := metadata.Client.Account.SubscriptionId

var appServiceEnvironmentV3 AppServiceEnvironmentV3Model
if err := metadata.Decode(&appServiceEnvironmentV3); err != nil {
return fmt.Errorf("decoding %+v", err)
}

id := parse.NewAppServiceEnvironmentID(subscriptionId, appServiceEnvironmentV3.ResourceGroup, appServiceEnvironmentV3.Name)

existing, err := client.Get(ctx, id.ResourceGroup, id.HostingEnvironmentName)
if err != nil {
if utils.ResponseWasNotFound(existing.Response) {
Expand All @@ -105,6 +119,7 @@ func (r AppServiceEnvironmentV3DataSource) Read() sdk.ResourceFunc {

model.Tags = tags.Flatten(existing.Tags)

metadata.SetID(id)
return metadata.Encode(&model)
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAccAppServiceEnvironmentV3DataSource_basic(t *testing.T) {
Config: AppServiceEnvironmentV3DataSource{}.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("cluster_setting.#").HasValue("2"),
check.That(data.ResourceName).Key("tags.#").HasValue("2"),
check.That(data.ResourceName).Key("tags.%").HasValue("2"),
),
},
})
Expand Down
4 changes: 4 additions & 0 deletions website/docs/d/app_service_environment_v3.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `cluster_setting` - A `cluster_setting` block as defined below.

* `location` - The location where the App Service Environment exists.

* `pricing_tier` - Pricing tier for the front end instances.

* `subnet_id` - The ID of the v3 App Service Environment Subnet.

* `tags` - A mapping of tags assigned to the v3 App Service Environment.
Expand Down