-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
New resource: azurerm_dedicated_hardware_security_module #7727
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -35,6 +35,7 @@ import ( | |||||
eventgrid "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/eventgrid/client" | ||||||
eventhub "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/eventhub/client" | ||||||
frontdoor "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/frontdoor/client" | ||||||
hardwaresecuritymodules "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/hardwaresecuritymodule/client" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||||||
hdinsight "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/hdinsight/client" | ||||||
healthcare "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/healthcare/client" | ||||||
iotcentral "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/iotcentral/client" | ||||||
|
@@ -89,80 +90,81 @@ type Client struct { | |||||
Account *ResourceManagerAccount | ||||||
Features features.UserFeatures | ||||||
|
||||||
Advisor *advisor.Client | ||||||
AnalysisServices *analysisServices.Client | ||||||
ApiManagement *apiManagement.Client | ||||||
AppConfiguration *appConfiguration.Client | ||||||
AppInsights *applicationInsights.Client | ||||||
AppPlatform *appPlatform.Client | ||||||
Authorization *authorization.Client | ||||||
Automation *automation.Client | ||||||
Batch *batch.Client | ||||||
Blueprints *blueprints.Client | ||||||
Bot *bot.Client | ||||||
Cdn *cdn.Client | ||||||
Cognitive *cognitiveServices.Client | ||||||
Compute *compute.Client | ||||||
Containers *containerServices.Client | ||||||
Cosmos *cosmosdb.Client | ||||||
CostManagement *costmanagement.Client | ||||||
CustomProviders *customproviders.Client | ||||||
DatabaseMigration *datamigration.Client | ||||||
DataBricks *databricks.Client | ||||||
DataFactory *datafactory.Client | ||||||
Datalake *datalake.Client | ||||||
DataShare *datashare.Client | ||||||
DevSpace *devspace.Client | ||||||
DevTestLabs *devtestlabs.Client | ||||||
Dns *dns.Client | ||||||
EventGrid *eventgrid.Client | ||||||
Eventhub *eventhub.Client | ||||||
Frontdoor *frontdoor.Client | ||||||
HDInsight *hdinsight.Client | ||||||
HealthCare *healthcare.Client | ||||||
IoTCentral *iotcentral.Client | ||||||
IoTHub *iothub.Client | ||||||
IoTTimeSeriesInsights *timeseriesinsights.Client | ||||||
KeyVault *keyvault.Client | ||||||
Kusto *kusto.Client | ||||||
LogAnalytics *loganalytics.Client | ||||||
Logic *logic.Client | ||||||
MachineLearning *machinelearning.Client | ||||||
Maintenance *maintenance.Client | ||||||
ManagedApplication *managedapplication.Client | ||||||
ManagementGroups *managementgroup.Client | ||||||
Maps *maps.Client | ||||||
MariaDB *mariadb.Client | ||||||
Media *media.Client | ||||||
MixedReality *mixedreality.Client | ||||||
Monitor *monitor.Client | ||||||
MSI *msi.Client | ||||||
MSSQL *mssql.Client | ||||||
MySQL *mysql.Client | ||||||
NetApp *netapp.Client | ||||||
Network *network.Client | ||||||
NotificationHubs *notificationhub.Client | ||||||
Policy *policy.Client | ||||||
Portal *portal.Client | ||||||
Postgres *postgres.Client | ||||||
PowerBI *powerBI.Client | ||||||
PrivateDns *privatedns.Client | ||||||
RecoveryServices *recoveryServices.Client | ||||||
Redis *redis.Client | ||||||
Relay *relay.Client | ||||||
Resource *resource.Client | ||||||
Search *search.Client | ||||||
SecurityCenter *securityCenter.Client | ||||||
Sentinel *sentinel.Client | ||||||
ServiceBus *serviceBus.Client | ||||||
ServiceFabric *serviceFabric.Client | ||||||
SignalR *signalr.Client | ||||||
Storage *storage.Client | ||||||
StreamAnalytics *streamAnalytics.Client | ||||||
Subscription *subscription.Client | ||||||
Sql *sql.Client | ||||||
TrafficManager *trafficManager.Client | ||||||
Web *web.Client | ||||||
Advisor *advisor.Client | ||||||
AnalysisServices *analysisServices.Client | ||||||
ApiManagement *apiManagement.Client | ||||||
AppConfiguration *appConfiguration.Client | ||||||
AppInsights *applicationInsights.Client | ||||||
AppPlatform *appPlatform.Client | ||||||
Authorization *authorization.Client | ||||||
Automation *automation.Client | ||||||
Batch *batch.Client | ||||||
Blueprints *blueprints.Client | ||||||
Bot *bot.Client | ||||||
Cdn *cdn.Client | ||||||
Cognitive *cognitiveServices.Client | ||||||
Compute *compute.Client | ||||||
Containers *containerServices.Client | ||||||
Cosmos *cosmosdb.Client | ||||||
CostManagement *costmanagement.Client | ||||||
CustomProviders *customproviders.Client | ||||||
DatabaseMigration *datamigration.Client | ||||||
DataBricks *databricks.Client | ||||||
DataFactory *datafactory.Client | ||||||
Datalake *datalake.Client | ||||||
DataShare *datashare.Client | ||||||
DevSpace *devspace.Client | ||||||
DevTestLabs *devtestlabs.Client | ||||||
Dns *dns.Client | ||||||
EventGrid *eventgrid.Client | ||||||
Eventhub *eventhub.Client | ||||||
Frontdoor *frontdoor.Client | ||||||
HardwareSecurityModules *hardwaresecuritymodules.Client | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||||||
HDInsight *hdinsight.Client | ||||||
HealthCare *healthcare.Client | ||||||
IoTCentral *iotcentral.Client | ||||||
IoTHub *iothub.Client | ||||||
IoTTimeSeriesInsights *timeseriesinsights.Client | ||||||
KeyVault *keyvault.Client | ||||||
Kusto *kusto.Client | ||||||
LogAnalytics *loganalytics.Client | ||||||
Logic *logic.Client | ||||||
MachineLearning *machinelearning.Client | ||||||
Maintenance *maintenance.Client | ||||||
ManagedApplication *managedapplication.Client | ||||||
ManagementGroups *managementgroup.Client | ||||||
Maps *maps.Client | ||||||
MariaDB *mariadb.Client | ||||||
Media *media.Client | ||||||
MixedReality *mixedreality.Client | ||||||
Monitor *monitor.Client | ||||||
MSI *msi.Client | ||||||
MSSQL *mssql.Client | ||||||
MySQL *mysql.Client | ||||||
NetApp *netapp.Client | ||||||
Network *network.Client | ||||||
NotificationHubs *notificationhub.Client | ||||||
Policy *policy.Client | ||||||
Portal *portal.Client | ||||||
Postgres *postgres.Client | ||||||
PowerBI *powerBI.Client | ||||||
PrivateDns *privatedns.Client | ||||||
RecoveryServices *recoveryServices.Client | ||||||
Redis *redis.Client | ||||||
Relay *relay.Client | ||||||
Resource *resource.Client | ||||||
Search *search.Client | ||||||
SecurityCenter *securityCenter.Client | ||||||
Sentinel *sentinel.Client | ||||||
ServiceBus *serviceBus.Client | ||||||
ServiceFabric *serviceFabric.Client | ||||||
SignalR *signalr.Client | ||||||
Storage *storage.Client | ||||||
StreamAnalytics *streamAnalytics.Client | ||||||
Subscription *subscription.Client | ||||||
Sql *sql.Client | ||||||
TrafficManager *trafficManager.Client | ||||||
Web *web.Client | ||||||
} | ||||||
|
||||||
// NOTE: it should be possible for this method to become Private once the top level Client's removed | ||||||
|
@@ -202,6 +204,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error | |||||
client.EventGrid = eventgrid.NewClient(o) | ||||||
client.Eventhub = eventhub.NewClient(o) | ||||||
client.Frontdoor = frontdoor.NewClient(o) | ||||||
client.HardwareSecurityModules = hardwaresecuritymodules.NewClient(o) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||||||
client.HDInsight = hdinsight.NewClient(o) | ||||||
client.HealthCare = healthcare.NewClient(o) | ||||||
client.IoTCentral = iotcentral.NewClient(o) | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -31,6 +31,7 @@ import ( | |||||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/eventgrid" | ||||||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/eventhub" | ||||||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/frontdoor" | ||||||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/hardwaresecuritymodule" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
and so on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||||||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/hdinsight" | ||||||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/healthcare" | ||||||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/iotcentral" | ||||||
|
@@ -111,6 +112,7 @@ func SupportedServices() []common.ServiceRegistration { | |||||
eventgrid.Registration{}, | ||||||
eventhub.Registration{}, | ||||||
frontdoor.Registration{}, | ||||||
hardwaresecuritymodule.Registration{}, | ||||||
hdinsight.Registration{}, | ||||||
healthcare.Registration{}, | ||||||
iothub.Registration{}, | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package client | ||
|
||
import ( | ||
"github.com/Azure/azure-sdk-for-go/services/preview/hardwaresecuritymodules/mgmt/2018-10-31-preview/hardwaresecuritymodules" | ||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" | ||
) | ||
|
||
type Client struct { | ||
DedicatedHsmClient *hardwaresecuritymodules.DedicatedHsmClient | ||
} | ||
|
||
func NewClient(o *common.ClientOptions) *Client { | ||
dedicatedHsmClient := hardwaresecuritymodules.NewDedicatedHsmClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) | ||
o.ConfigureClient(&dedicatedHsmClient.Client, o.ResourceManagerAuthorizer) | ||
|
||
return &Client{ | ||
DedicatedHsmClient: &dedicatedHsmClient, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package parse | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" | ||
) | ||
|
||
type DedicatedHardwareSecurityModuleId struct { | ||
ResourceGroup string | ||
Name string | ||
} | ||
|
||
func DedicatedHardwareSecurityModuleID(input string) (*DedicatedHardwareSecurityModuleId, error) { | ||
id, err := azure.ParseAzureResourceID(input) | ||
if err != nil { | ||
return nil, fmt.Errorf("parsing DedicatedHardwareSecurityModule ID %q: %+v", input, err) | ||
} | ||
|
||
dedicatedHardwareSecurityModule := DedicatedHardwareSecurityModuleId{ | ||
ResourceGroup: id.ResourceGroup, | ||
} | ||
|
||
if dedicatedHardwareSecurityModule.Name, err = id.PopSegment("dedicatedHSMs"); err != nil { | ||
return nil, err | ||
} | ||
|
||
if err := id.ValidateNoEmptySegments(input); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &dedicatedHardwareSecurityModule, nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package parse | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestDedicatedHardwareSecurityModuleID(t *testing.T) { | ||
testData := []struct { | ||
Name string | ||
Input string | ||
Expected *DedicatedHardwareSecurityModuleId | ||
}{ | ||
{ | ||
Name: "Empty", | ||
Input: "", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "No Resource Groups Segment", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "No Resource Groups Value", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Resource Group ID", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Missing DedicatedHardwareSecurityModule Value", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "DedicatedHardwareSecurityModule ID", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/hsm1", | ||
Expected: &DedicatedHardwareSecurityModuleId{ | ||
ResourceGroup: "group1", | ||
Name: "hsm1", | ||
}, | ||
}, | ||
{ | ||
Name: "Wrong Casing", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.HardwareSecurityModules/DedicatedHSMs/hsm1", | ||
Expected: nil, | ||
}, | ||
} | ||
|
||
for _, v := range testData { | ||
t.Logf("[DEBUG] Testing %q..", v.Name) | ||
|
||
actual, err := DedicatedHardwareSecurityModuleID(v.Input) | ||
if err != nil { | ||
if v.Expected == nil { | ||
continue | ||
} | ||
t.Fatalf("Expected a value but got an error: %s", err) | ||
} | ||
|
||
if actual.ResourceGroup != v.Expected.ResourceGroup { | ||
t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) | ||
} | ||
|
||
if actual.Name != v.Expected.Name { | ||
t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package hardwaresecuritymodule | ||
|
||
import "github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
|
||
type Registration struct{} | ||
|
||
// Name is the name of this Service | ||
func (r Registration) Name() string { | ||
return "Hardware Security Module" | ||
} | ||
|
||
// WebsiteCategories returns a list of categories which can be used for the sidebar | ||
func (r Registration) WebsiteCategories() []string { | ||
return []string{ | ||
"Hardware Security Module", | ||
} | ||
} | ||
|
||
// SupportedDataSources returns the supported Data Sources supported by this Service | ||
func (r Registration) SupportedDataSources() map[string]*schema.Resource { | ||
return map[string]*schema.Resource{} | ||
} | ||
|
||
// SupportedResources returns the supported Resources supported by this Service | ||
func (r Registration) SupportedResources() map[string]*schema.Resource { | ||
return map[string]*schema.Resource{ | ||
"azurerm_dedicated_hardware_security_module": resourceArmDedicatedHardwareSecurityModule(), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit long, could we maybe abbreviate it to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated