Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-yechenwei committed Apr 28, 2023
2 parents 7c72b87 + d735d0e commit 962e27f
Show file tree
Hide file tree
Showing 454 changed files with 10,595 additions and 4,442 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- main
paths:
- '.github/workflows/mkdocs.yaml'
- 'contributing/**'
workflow_dispatch:

Expand All @@ -21,7 +22,7 @@ jobs:
uses: actions/checkout@v3

- name: Publish
uses: mhausenblas/mkdocs-deploy-gh-pages@master
uses: mhausenblas/mkdocs-deploy-gh-pages@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONFIG_FILE: mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
types: ["opened", "synchronize"]
paths:
- ".github/workflows/provider-test.yml"
- '.github/workflows/provider-test.yaml'
- 'internal/**.go'
- 'vendor/github.com/hashicorp/go-azure-sdk/sdk/auth/**'
- 'vendor/github.com/hashicorp/go-azure-sdk/sdk/environments/**'
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ website/vendor

.vscode/

# mkdocs output
site/

# Test exclusions
!command/test-fixtures/**/*.tfstate
!command/test-fixtures/**/.terraform/
Expand Down
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ FEATURES:

* **New Resource:** `azurerm_arc_kubernetes_cluster_extension` [GH-21310]
* **New Resource:** `azurerm_cosmosdb_postgresql_cluster` [GH-21090]
* **New Resource:** `azurerm_email_communication_service` [GH-21526]
* **New Resource:** `azurerm_kubernetes_cluster_extension` [GH-21310]
* **New Resource:** `azurerm_netapp_volume_group_sap_hana` [GH-21290]
* **New Resource:** `azurerm_storage_mover_project` [GH-21477]
* **New Resource:** `azurerm_storage_mover_job_definition` [GH-21514]

ENHANCEMENTS:

* authentication: loading the access token expiry time from the Azure CLI when using this authentication method (#21460 and https://github.com/hashicorp/go-azure-sdk/pull/415)
* dependencies: updating to `v0.20230425.1021638` of `github.com/hashicorp/go-azure-sdk` [GH-21557]
* `security`: updating to API Version `2023-01-01` [GH-21531]
* dependencies: updating to `v0.20230427.1112058` of `github.com/hashicorp/go-azure-sdk` [GH-21583]
* `security`: updating to API Version `2023-01-01` [GH-21531]
* Data Source: `azurerm_virtual_network_gateway` - add support for the field `private_ip_address` [GH-21432]
* `azurerm_active_directory_domain_service` - `domain_name` now supports a length up to 30 characters [GH-21555]
* `azurerm_attestation_provider` - adding support for the field `open_enclave_policy_base64`, `sgx_enclave_policy_base64` and `tpm_policy_base64` [GH-21524]
* `azurerm_attestation_provider` - adding support for the field `sgx_enclave_policy_base64` [GH-21524]
* `azurerm_attestation_provider` - adding support for the field `tpm_policy_base64` [GH-21524]
Expand All @@ -34,6 +36,7 @@ ENHANCEMENTS:

BUG FIXES:

* **Provider:** fix an authentication bug when specifying `auxiliary_tenant_ids` whilst authenticating using Azure CLI [GH-21583]
* `azurerm_attestation_provider` - the field `policy` is deprecated and non-functional - instead please use the fields `open_enclave_policy_base64`, `sgx_enclave_policy_base64` and `tpm_policy_base64` [GH-21524]
* `azurerm_mysql_flexible_server` - fix issue where `identity` was not being removed properly on updates [GH-21533]
* `azurerm_search_service` - updating the default value for `partition_count` to `1` to match the API [GH-21323]
Expand Down
4 changes: 2 additions & 2 deletions contributing/topics/guide-new-data-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ package resource

In this case, you need to specify the `name` the Resource (in this case `ResourceGroupExample`) and the `id` which is an example of this Resource ID (in this case `/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1`).

> The segments of the Resource ID should be camelCased (e.g. `resourceGroups` rather than `resourcegroups`) per the Azure API Specification - see [the Azure Resource ID reference](reference-azure-resource-ids.md) for more information.
> The segments of the Resource ID should be camelCased (e.g. `resourceGroups` rather than `resourcegroups`) per the Azure API Specification - see [Azure Resource IDs in the Glossary](reference-glossary.md#azure-resource-ids) for more information.
You can generate the Resource ID Struct, Parser and Validation functions by running `make generate` - which will output the following files:

* `./internal/service/resource/parse/resource_group_example.go` - contains the Resource ID Struct, Formatter and Parser.
* `./internal/service/resource/parse/resource_group_example_test.go` - contains tests for those ^.
* `./internal/service/resource/validate/resource_group_example_id.go` - contains Terraform validation functions for the Resource ID.

These types can then be used in the Data Source we're creating below, but [see this link for more information on how Azure Resource ID's are used in Terraform](reference-azure-resource-ids.md).
These types can then be used in the Data Source we're creating below.

### Step 4: Scaffold an empty/new Data Source

Expand Down
4 changes: 2 additions & 2 deletions contributing/topics/guide-new-resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ package resource

In this case, you need to specify the `name` the Resource (in this case `ResourceGroupExample`) and the `id` which is an example of this Resource ID (in this case `/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1`).

> The segments of the Resource ID should be camelCased (e.g. `resourceGroups` rather than `resourcegroups`) per the Azure API Specification - see [the Azure Resource ID reference](reference-azure-resource-ids.md) for more information.
> The segments of the Resource ID should be camelCased (e.g. `resourceGroups` rather than `resourcegroups`) per the Azure API Specification - see [Azure Resource IDs in the Glossary](reference-glossary.md#azure-resource-ids) for more information.
You can generate the Resource ID Struct, Parser and Validation functions by running `make generate` - which will output the following files:

* `./internal/service/resource/parse/resource_group_example.go` - contains the Resource ID Struct, Formatter and Parser.
* `./internal/service/resource/parse/resource_group_example_test.go` - contains tests for those ^.
* `./internal/service/resource/validate/resource_group_example_id.go` - contains Terraform validation functions for the Resource ID.

These types can then be used in the Resource we're creating below, but [see this link for more information on how Azure Resource ID's are used in Terraform](reference-azure-resource-ids.md).
These types can then be used in the Resource we're creating below.

### Step 4: Scaffold an empty/new Resource

Expand Down
4 changes: 2 additions & 2 deletions contributing/topics/high-level-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Some Service Packages may also contain:

* `./migration` - any State Migrations used in Resources.
* `./sdk` - any Embedded SDK’s used to access the Azure API’s (either Resource Manager or Data Plane).
* `./resourceids.go` - used to generate Resource ID Formatters, Parsers and Validators, see [Resource ID Generation](resource-id-generation.md) for more information.
* `./resourceids.go` - used to generate Resource ID Formatters, Parsers and Validators.

—-

Expand Down Expand Up @@ -123,4 +123,4 @@ At this point in time, each of the SDKs mentioned above (excluding Hamilton) mak

Since the behaviour of the Azure API can change over time, the Provider leans on Acceptance Tests over Unit Tests for asserting that the Data Sources and Resources within the Provider work as expected.

More details and guidance on how to test Data Sources/Resources can be found in [the Acceptance Testing reference](reference-acceptance-testing.md).
More details and guidance on how to test Data Sources/Resources can be found in [the Acceptance Testing reference](reference-acceptance-testing.md).
4 changes: 2 additions & 2 deletions contributing/topics/reference-acceptance-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ At a minimum, a Resource requires:

* A `basic` test ([Example](#Example---Basic---Resource)) - this tests the minimum fields (e.g. all Required fields) for this Resource.

* A `requiresImport` test ([Example](#Example---Resource---Requires-Import)) - this test exercises the logic in the `create` function of a resource that checks for the prior existence of the resource and being created and expects an error. See [requires-import](requires-import.md). The acceptance test package provides a helper function is provided to be used in the test, called `RequiresImportErrorStep` for this purpose.
* A `requiresImport` test ([Example](#Example---Resource---Requires-Import)) - this test exercises the logic in the `create` function of a resource that checks for the prior existence of the resource and being created and expects an error. The acceptance test package provides a helper function is provided to be used in the test, called `RequiresImportErrorStep` for this purpose.

* A `complete` test ([Example](#Example---Resource---Complete)) - this tests all possible fields (e.g. all Required/Optional fields) for this Resource.

Expand Down Expand Up @@ -351,4 +351,4 @@ resource "azurerm_example_resource" "example" {
}
`, data.Locations.Primary)
}
```
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.1.2
github.com/hashicorp/go-azure-helpers v0.55.0
github.com/hashicorp/go-azure-sdk v0.20230425.1021638
github.com/hashicorp/go-azure-sdk v0.20230427.1141117
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/go-version v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv
github.com/hashicorp/go-azure-helpers v0.12.0/go.mod h1:Zc3v4DNeX6PDdy7NljlYpnrdac1++qNW0I4U+ofGwpg=
github.com/hashicorp/go-azure-helpers v0.55.0 h1:2A2KWPiaDC5kQWr6tYHTD/P1k9bO0HvflEb/Nc1yLeU=
github.com/hashicorp/go-azure-helpers v0.55.0/go.mod h1:RQugkG8wEcNIjYmcBLHpuEI/u2mTJwO4r37rR/OKRpo=
github.com/hashicorp/go-azure-sdk v0.20230425.1021638 h1:wcjnJrXaDZP6wbykZKG98+vx+87iwWYjGjlqU6RERtk=
github.com/hashicorp/go-azure-sdk v0.20230425.1021638/go.mod h1:L9JXVUcnL0GjMizCnngYUlMp1lLhDBNgSTvn6Of/5O4=
github.com/hashicorp/go-azure-sdk v0.20230427.1141117 h1:dJY0gZEsRd+Zpn5e2g5GWNx7K0OzcweA4daviO7NZHQ=
github.com/hashicorp/go-azure-sdk v0.20230427.1141117/go.mod h1:L9JXVUcnL0GjMizCnngYUlMp1lLhDBNgSTvn6Of/5O4=
github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=
github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
Expand Down
8 changes: 2 additions & 6 deletions internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,12 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
if client.DataProtection, err = dataprotection.NewClient(o); err != nil {
return fmt.Errorf("building clients for DataProtection: %+v", err)
}
if client.DataShare, err = datashare.NewClient(o); err != nil {
return fmt.Errorf("building clients for DataShare: %+v", err)
}
client.DataShare = datashare.NewClient(o)
if client.DesktopVirtualization, err = desktopvirtualization.NewClient(o); err != nil {
return fmt.Errorf("building clients for DesktopVirtualization: %+v", err)
}
client.DevTestLabs = devtestlabs.NewClient(o)
if client.DigitalTwins, err = digitaltwins.NewClient(o); err != nil {
return fmt.Errorf("building clients for DigitalTwins: %+v", err)
}
client.DigitalTwins = digitaltwins.NewClient(o)
client.Disks = disks.NewClient(o)
if client.Dns, err = dns.NewClient(o); err != nil {
return fmt.Errorf("building clients for Dns: %+v", err)
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration {
batch.Registration{},
bot.Registration{},
cognitive.Registration{},
communication.Registration{},
compute.Registration{},
consumption.Registration{},
cosmos.Registration{},
containerapps.Registration{},
cosmos.Registration{},
costmanagement.Registration{},
dashboard.Registration{},
databoxedge.Registration{},
Expand Down Expand Up @@ -205,7 +206,6 @@ func SupportedUntypedServices() []sdk.UntypedServiceRegistration {
bot.Registration{},
cdn.Registration{},
cognitive.Registration{},
communication.Registration{},
compute.Registration{},
confidentialledger.Registration{},
connections.Registration{},
Expand Down
20 changes: 10 additions & 10 deletions internal/services/attestation/attestation_provider_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/attestation/2020-10-01/attestation"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
Expand All @@ -22,6 +21,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/attestation/2022-08-01/attestation"
)

func resourceAttestationProvider() *pluginsdk.Resource {
Expand Down Expand Up @@ -173,17 +173,17 @@ func resourceAttestationProviderCreate(d *pluginsdk.ResourceData, meta interface
}

if v := d.Get("open_enclave_policy_base64"); v != "" {
if _, err = dataPlaneClient.Set(ctx, *dataPlaneUri, attestation.OpenEnclave, d.Get("open_enclave_policy_base64").(string)); err != nil {
if _, err = dataPlaneClient.Set(ctx, *dataPlaneUri, attestation.TypeOpenEnclave, d.Get("open_enclave_policy_base64").(string)); err != nil {
return fmt.Errorf("updating value for `open_enclave_policy_base64`: %+v", err)
}
}
if v := d.Get("sgx_enclave_policy_base64"); v != "" {
if _, err = dataPlaneClient.Set(ctx, *dataPlaneUri, attestation.SgxEnclave, d.Get("sgx_enclave_policy_base64").(string)); err != nil {
if _, err = dataPlaneClient.Set(ctx, *dataPlaneUri, attestation.TypeSgxEnclave, d.Get("sgx_enclave_policy_base64").(string)); err != nil {
return fmt.Errorf("updating value for `sgx_enclave_policy_base64`: %+v", err)
}
}
if v := d.Get("tpm_policy_base64"); v != "" {
if _, err = dataPlaneClient.Set(ctx, *dataPlaneUri, attestation.Tpm, d.Get("tpm_policy_base64").(string)); err != nil {
if _, err = dataPlaneClient.Set(ctx, *dataPlaneUri, attestation.TypeTpm, d.Get("tpm_policy_base64").(string)); err != nil {
return fmt.Errorf("updating value for `tpm_policy_base64`: %+v", err)
}
}
Expand Down Expand Up @@ -221,15 +221,15 @@ func resourceAttestationProviderRead(d *pluginsdk.ResourceData, meta interface{}
}

// Status=400 Code="Bad request" Message="Tpm attestation is not supported in the 'UKSouth' region"
openEnclavePolicy, err := dataPlaneClient.Get(ctx, *dataPlaneUri, attestation.OpenEnclave)
openEnclavePolicy, err := dataPlaneClient.Get(ctx, *dataPlaneUri, attestation.TypeOpenEnclave)
if err != nil && !utils.ResponseWasBadRequest(openEnclavePolicy.Response) {
return fmt.Errorf("retrieving OpenEnclave Policy for %s: %+v", *id, err)
}
sgxEnclavePolicy, err := dataPlaneClient.Get(ctx, *dataPlaneUri, attestation.SgxEnclave)
sgxEnclavePolicy, err := dataPlaneClient.Get(ctx, *dataPlaneUri, attestation.TypeSgxEnclave)
if err != nil && !utils.ResponseWasBadRequest(sgxEnclavePolicy.Response) {
return fmt.Errorf("retrieving SgxEnclave Policy for %s: %+v", *id, err)
}
tpmPolicy, err := dataPlaneClient.Get(ctx, *dataPlaneUri, attestation.Tpm)
tpmPolicy, err := dataPlaneClient.Get(ctx, *dataPlaneUri, attestation.TypeTpm)
if err != nil && !utils.ResponseWasBadRequest(tpmPolicy.Response) {
return fmt.Errorf("retrieving Tpm Policy for %s: %+v", *id, err)
}
Expand Down Expand Up @@ -307,17 +307,17 @@ func resourceAttestationProviderUpdate(d *pluginsdk.ResourceData, meta interface
}

if d.HasChange("open_enclave_policy_base64") {
if _, err = dataPlaneClient.Set(ctx, *dataPlaneUri, attestation.OpenEnclave, d.Get("open_enclave_policy_base64").(string)); err != nil {
if _, err = dataPlaneClient.Set(ctx, *dataPlaneUri, attestation.TypeOpenEnclave, d.Get("open_enclave_policy_base64").(string)); err != nil {
return fmt.Errorf("updating value for `open_enclave_policy_base64`: %+v", err)
}
}
if d.HasChange("sgx_enclave_policy_base64") {
if _, err = dataPlaneClient.Set(ctx, *dataPlaneUri, attestation.SgxEnclave, d.Get("sgx_enclave_policy_base64").(string)); err != nil {
if _, err = dataPlaneClient.Set(ctx, *dataPlaneUri, attestation.TypeSgxEnclave, d.Get("sgx_enclave_policy_base64").(string)); err != nil {
return fmt.Errorf("updating value for `sgx_enclave_policy_base64`: %+v", err)
}
}
if d.HasChange("tpm_policy_base64") {
if _, err = dataPlaneClient.Set(ctx, *dataPlaneUri, attestation.Tpm, d.Get("tpm_policy_base64").(string)); err != nil {
if _, err = dataPlaneClient.Set(ctx, *dataPlaneUri, attestation.TypeTpm, d.Get("tpm_policy_base64").(string)); err != nil {
return fmt.Errorf("updating value for `tpm_policy_base64`: %+v", err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/services/attestation/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"net/url"
"strings"

"github.com/Azure/azure-sdk-for-go/services/attestation/2020-10-01/attestation"
"github.com/hashicorp/go-azure-sdk/resource-manager/attestation/2020-10-01/attestationproviders"
authWrapper "github.com/hashicorp/go-azure-sdk/sdk/auth/autorest"
"github.com/hashicorp/go-azure-sdk/sdk/environments"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
"github.com/tombuildsstuff/kermit/sdk/attestation/2022-08-01/attestation"
)

type Client struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"strings"

"github.com/Azure/azure-sdk-for-go/services/attestation/2020-10-01/attestation"
"github.com/tombuildsstuff/kermit/sdk/attestation/2022-08-01/attestation"
)

func ContainsABase64UriEncodedJWTOfAStoredAttestationPolicy(value interface{}, key string) (warnings []string, errors []error) {
Expand Down
20 changes: 15 additions & 5 deletions internal/services/communication/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,32 @@ package client
import (
"fmt"

"github.com/hashicorp/go-azure-sdk/resource-manager/communication/2020-08-20/communicationservice"
"github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/communicationservices"
"github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/emailservices"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

type Client struct {
ServiceClient *communicationservice.CommunicationServiceClient
ServiceClient *communicationservices.CommunicationServicesClient

EmailServicesClient *emailservices.EmailServicesClient
}

func NewClient(o *common.ClientOptions) (*Client, error) {
serviceClient, err := communicationservice.NewCommunicationServiceClientWithBaseURI(o.Environment.ResourceManager)
servicesClient, err := communicationservices.NewCommunicationServicesClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Service client: %+v", err)
}
o.Configure(serviceClient.Client, o.Authorizers.ResourceManager)
o.Configure(servicesClient.Client, o.Authorizers.ResourceManager)

emailServicesClient, err := emailservices.NewEmailServicesClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Email Service client: %+v", err)
}
o.Configure(emailServicesClient.Client, o.Authorizers.ResourceManager)

return &Client{
ServiceClient: serviceClient,
ServiceClient: servicesClient,
EmailServicesClient: emailServicesClient,
}, nil
}

0 comments on commit 962e27f

Please sign in to comment.