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

Add new resource & data source: azurerm_disk_encryption_set #5249

Merged
merged 15 commits into from
Jan 10, 2020

Conversation

ArcturusZhang
Copy link
Contributor

@ArcturusZhang ArcturusZhang commented Dec 25, 2019

This is part of update of the SSE-CMK feature, adding a new resource and a data source: azurerm_disk_encryption_set.

This feature requires Keyvault to enable enable_soft_delete and enable_purge_protection, which are both not implemented in terraform. And the creation of azurerm_disk_encryption_set depends on those two switches, otherwise the service will return errors complaining about this.
Therefore I did some workaround in the test of azurerm_disk_encryption_set. I will change the workaround back when these two features are implemented in azurerm_key_vault.

Currently the fields that could accept user input in a DiskEncryptionSet is all required, therefore I do not put a complete test, since all the fields are covered in the basic test.

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @ArcturusZhang

Thanks for this PR - I've taken a look through and left some comments inline but this is off to a good start - if we can fix those up then we should be able to run the acceptance tests and take another look :)

Thanks!

website/docs/r/disk_encryption_set.html.markdown Outdated Show resolved Hide resolved
return fmt.Errorf("Error setting `previous_keys`: %+v", err)
}
}
if identity := resp.Identity; identity != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to ensure that identity is set in all circumstances, so we can move this check inside the flatten function


Manage an Azure DiskEncryptionSet instance.

-> **NOTE:** The DiskEncryptionSet service is currently in public preview and are only available in a limited set of regions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make the phrasing consistent with other resources:

Suggested change
-> **NOTE:** The DiskEncryptionSet service is currently in public preview and are only available in a limited set of regions.
-> **NOTE:** Disk Encryption Sets are currently in Public Preview and are only available in a limited set of regions.

how do users opt-into this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me ask the service team and then fill this information in.

Manage an Azure DiskEncryptionSet instance.

-> **NOTE:** The DiskEncryptionSet service is currently in public preview and are only available in a limited set of regions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this requires that the Key Vault is configured in a particular way - can we also document that here:


-> **NOTE:** At this time the Key Vault used to store the Active Key for this Disk Encryption Set must have both Soft Delete & Purge Protection enabled - which are not yet supported by Terraform - instead you can configure this using [a provisioner](https://www.terraform.io/docs/provisioners/local-exec.html) or [the `azurerm_template_deployment` resource](https://www.terraform.io/docs/providers/azurerm/r/template_deployment.html).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. And do you think we should add the provisioner command in the example?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 - no this isn't something we'd recommend doing until it's natively supported (but that's blocked on the API issue mentioned above)

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @ArcturusZhang

Thanks for this PR - I've taken a look through and left some comments inline but this is off to a good start - if we can fix those up then we should be able to run the acceptance tests and take another look :)

Thanks!

@tombuildsstuff
Copy link
Contributor

Sorry for the double review - Github bug 🙃

@ArcturusZhang
Copy link
Contributor Author

Hi @tombuildsstuff I have resolved some comments, and left some replies. Please have a look.
Additionally, I cannot pass the acctest on my side now. It works well when I am submitting this PR.
It reports:

=== RUN   TestAccAzureRMDiskEncryptionSet_basic
=== PAUSE TestAccAzureRMDiskEncryptionSet_basic
=== CONT  TestAccAzureRMDiskEncryptionSet_basic
--- FAIL: TestAccAzureRMDiskEncryptionSet_basic (0.07s)
    testing.go:569: Step 0 error: Error initializing context: 2 problems:

        - Could not satisfy plugin requirements:
        Plugin reinitialization required. Please run "terraform init".

        Plugins are external binaries that Terraform uses to access and manipulate
        resources. The configuration provided requires plugins which can't be located,
        don't satisfy the version constraints, or are otherwise incompatible.

        Terraform automatically discovers provider requirements from your
        configuration, including providers used in child modules. To see the
        requirements and constraints from each module, run "terraform providers".

        - provider "azurerm" is not available

Could you please help me on this? What is possibly causing this error? Or is there some kinds of caches terraform are using during the acctest?

@ArcturusZhang
Copy link
Contributor Author

Hi @tombuildsstuff I have fixed the acc-tests:

=== RUN   TestAccAzureRMDiskEncryptionSet_basic
=== PAUSE TestAccAzureRMDiskEncryptionSet_basic
=== CONT  TestAccAzureRMDiskEncryptionSet_basic
--- PASS: TestAccAzureRMDiskEncryptionSet_basic (367.77s)
PASS
=== RUN   TestAccDataSourceAzureRMDiskEncryptionSet_basic
=== PAUSE TestAccDataSourceAzureRMDiskEncryptionSet_basic
=== CONT  TestAccDataSourceAzureRMDiskEncryptionSet_basic
--- PASS: TestAccDataSourceAzureRMDiskEncryptionSet_basic (428.47s)
PASS

@tombuildsstuff
Copy link
Contributor

@ArcturusZhang hope you don't mind but I've rebased this on top of master to fix the merge conflicts

@ArcturusZhang
Copy link
Contributor Author

ArcturusZhang commented Jan 10, 2020

@ArcturusZhang hope you don't mind but I've rebased this on top of master to fix the merge conflicts

Sure, thanks.
But the CI is failing on website-lint, how do I fix this? Because i did not really catch any useful information on the log

@ArcturusZhang
Copy link
Contributor Author

Hi @tombuildsstuff I should have fixed the CI failure, please have a look 🚀

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @ArcturusZhang

Thanks for pushing those changes - I've taken a look through and left some extra comments inline here. Since this is a Preview feature I've taken a closer look at this and noticed that the API Documentation is incorrect for the identity field - insofar as this is Required rather than Optional.

As such I hope you don't mind but so that we can get this merged I'm going to push a couple of commits to resolve these comments (and also hard-code the test location for the moment to work around the limited regions supported by the Preview).

Thanks!

if location := resp.Location; location != nil {
d.Set("location", azure.NormalizeLocation(*location))
}
if encryptionSetProperties := resp.EncryptionSetProperties; encryptionSetProperties != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor to match everything else can we use props here

website/docs/r/disk_encryption_set.html.markdown Outdated Show resolved Hide resolved
@ghost ghost added size/XXL and removed size/XL labels Jan 10, 2020
@tombuildsstuff
Copy link
Contributor

Tests pass:

Screenshot 2020-01-10 at 11 53 44

@tombuildsstuff tombuildsstuff merged commit f553c07 into hashicorp:master Jan 10, 2020
tombuildsstuff added a commit that referenced this pull request Jan 10, 2020
@ArcturusZhang ArcturusZhang deleted the DiskEncryptionSet branch January 10, 2020 14:12
@ArcturusZhang
Copy link
Contributor Author

Thanks @tombuildsstuff !

@ghost
Copy link

ghost commented Jan 16, 2020

This has been released in version 1.41.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 1.41.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Mar 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants