Skip to content

Commit e609934

Browse files
Adding support for posture resource in terraform provider (#9516) (#6890)
* add posture converter * modify posture.yaml * add create test * add SHA mapping * add create test * fix create test * add update test * fix field description * fix update posture * add comments to diff-suppress function * modify comments * modify posture * update posture exactly_one_of fields * fix exactly-one field * add locations field * remove exactly_one_of field * fix example formatting * change posture id description * modify update test * address review comments * add reference * add revision diff * fix custom constraint diff --------- [upstream:015ee2e68a94e10e5b63686772fe6cb879fceedc] Signed-off-by: Modular Magician <[email protected]>
1 parent c378c43 commit e609934

File tree

15 files changed

+3780
-2
lines changed

15 files changed

+3780
-2
lines changed

.changelog/9516.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_securityposture_posture`
3+
```

.teamcity/components/generated/services.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,11 @@ var services = mapOf(
566566
"displayName" to "Securitycenter",
567567
"path" to "./google-beta/services/securitycenter"
568568
),
569+
"securityposture" to mapOf(
570+
"name" to "securityposture",
571+
"displayName" to "Securityposture",
572+
"path" to "./google-beta/services/securityposture"
573+
),
569574
"securityscanner" to mapOf(
570575
"name" to "securityscanner",
571576
"displayName" to "Securityscanner",

google-beta/fwmodels/provider_model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ type ProviderModel struct {
128128
SecretManagerCustomEndpoint types.String `tfsdk:"secret_manager_custom_endpoint"`
129129
SecureSourceManagerCustomEndpoint types.String `tfsdk:"secure_source_manager_custom_endpoint"`
130130
SecurityCenterCustomEndpoint types.String `tfsdk:"security_center_custom_endpoint"`
131+
SecuritypostureCustomEndpoint types.String `tfsdk:"securityposture_custom_endpoint"`
131132
SecurityScannerCustomEndpoint types.String `tfsdk:"security_scanner_custom_endpoint"`
132133
ServiceDirectoryCustomEndpoint types.String `tfsdk:"service_directory_custom_endpoint"`
133134
ServiceManagementCustomEndpoint types.String `tfsdk:"service_management_custom_endpoint"`

google-beta/fwprovider/framework_provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
749749
transport_tpg.CustomEndpointValidator(),
750750
},
751751
},
752+
"securityposture_custom_endpoint": &schema.StringAttribute{
753+
Optional: true,
754+
Validators: []validator.String{
755+
transport_tpg.CustomEndpointValidator(),
756+
},
757+
},
752758
"security_scanner_custom_endpoint": &schema.StringAttribute{
753759
Optional: true,
754760
Validators: []validator.String{

google-beta/fwtransport/framework_config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ type FrameworkProviderConfig struct {
153153
SecretManagerBasePath string
154154
SecureSourceManagerBasePath string
155155
SecurityCenterBasePath string
156+
SecuritypostureBasePath string
156157
SecurityScannerBasePath string
157158
ServiceDirectoryBasePath string
158159
ServiceManagementBasePath string
@@ -313,6 +314,7 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context,
313314
p.SecretManagerBasePath = data.SecretManagerCustomEndpoint.ValueString()
314315
p.SecureSourceManagerBasePath = data.SecureSourceManagerCustomEndpoint.ValueString()
315316
p.SecurityCenterBasePath = data.SecurityCenterCustomEndpoint.ValueString()
317+
p.SecuritypostureBasePath = data.SecuritypostureCustomEndpoint.ValueString()
316318
p.SecurityScannerBasePath = data.SecurityScannerCustomEndpoint.ValueString()
317319
p.ServiceDirectoryBasePath = data.ServiceDirectoryCustomEndpoint.ValueString()
318320
p.ServiceManagementBasePath = data.ServiceManagementCustomEndpoint.ValueString()
@@ -1275,6 +1277,14 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
12751277
data.SecurityCenterCustomEndpoint = types.StringValue(customEndpoint.(string))
12761278
}
12771279
}
1280+
if data.SecuritypostureCustomEndpoint.IsNull() {
1281+
customEndpoint := transport_tpg.MultiEnvDefault([]string{
1282+
"GOOGLE_SECURITYPOSTURE_CUSTOM_ENDPOINT",
1283+
}, transport_tpg.DefaultBasePaths[transport_tpg.SecuritypostureBasePathKey])
1284+
if customEndpoint != nil {
1285+
data.SecuritypostureCustomEndpoint = types.StringValue(customEndpoint.(string))
1286+
}
1287+
}
12781288
if data.SecurityScannerCustomEndpoint.IsNull() {
12791289
customEndpoint := transport_tpg.MultiEnvDefault([]string{
12801290
"GOOGLE_SECURITY_SCANNER_CUSTOM_ENDPOINT",

google-beta/provider/provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,11 @@ func Provider() *schema.Provider {
645645
Optional: true,
646646
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
647647
},
648+
"securityposture_custom_endpoint": {
649+
Type: schema.TypeString,
650+
Optional: true,
651+
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
652+
},
648653
"security_scanner_custom_endpoint": {
649654
Type: schema.TypeString,
650655
Optional: true,
@@ -1043,6 +1048,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
10431048
config.SecretManagerBasePath = d.Get("secret_manager_custom_endpoint").(string)
10441049
config.SecureSourceManagerBasePath = d.Get("secure_source_manager_custom_endpoint").(string)
10451050
config.SecurityCenterBasePath = d.Get("security_center_custom_endpoint").(string)
1051+
config.SecuritypostureBasePath = d.Get("securityposture_custom_endpoint").(string)
10461052
config.SecurityScannerBasePath = d.Get("security_scanner_custom_endpoint").(string)
10471053
config.ServiceDirectoryBasePath = d.Get("service_directory_custom_endpoint").(string)
10481054
config.ServiceManagementBasePath = d.Get("service_management_custom_endpoint").(string)

google-beta/provider/provider_mmv1_resources.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ import (
107107
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/secretmanager"
108108
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/securesourcemanager"
109109
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/securitycenter"
110+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/securityposture"
110111
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/securityscanner"
111112
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/servicedirectory"
112113
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/servicemanagement"
@@ -423,9 +424,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
423424
}
424425

425426
// Resources
426-
// Generated resources: 423
427+
// Generated resources: 424
427428
// Generated IAM resources: 255
428-
// Total generated resources: 678
429+
// Total generated resources: 679
429430
var generatedResources = map[string]*schema.Resource{
430431
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
431432
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
@@ -1015,6 +1016,7 @@ var generatedResources = map[string]*schema.Resource{
10151016
"google_scc_source_iam_binding": tpgiamresource.ResourceIamBinding(securitycenter.SecurityCenterSourceIamSchema, securitycenter.SecurityCenterSourceIamUpdaterProducer, securitycenter.SecurityCenterSourceIdParseFunc),
10161017
"google_scc_source_iam_member": tpgiamresource.ResourceIamMember(securitycenter.SecurityCenterSourceIamSchema, securitycenter.SecurityCenterSourceIamUpdaterProducer, securitycenter.SecurityCenterSourceIdParseFunc),
10171018
"google_scc_source_iam_policy": tpgiamresource.ResourceIamPolicy(securitycenter.SecurityCenterSourceIamSchema, securitycenter.SecurityCenterSourceIamUpdaterProducer, securitycenter.SecurityCenterSourceIdParseFunc),
1019+
"google_securityposture_posture": securityposture.ResourceSecurityposturePosture(),
10181020
"google_security_scanner_scan_config": securityscanner.ResourceSecurityScannerScanConfig(),
10191021
"google_service_directory_endpoint": servicedirectory.ResourceServiceDirectoryEndpoint(),
10201022
"google_service_directory_namespace": servicedirectory.ResourceServiceDirectoryNamespace(),

0 commit comments

Comments
 (0)