@@ -458,7 +458,7 @@ type gcsDestinationModel struct {
458458 KeyPrefix types.String `tfsdk:"key_prefix"`
459459 StorageClass types.String `tfsdk:"storage_class"`
460460 Acl types.String `tfsdk:"acl"`
461- Auth gcpAuthModel `tfsdk:"auth"`
461+ Auth * gcpAuthModel `tfsdk:"auth"`
462462 Metadata []metadataEntry `tfsdk:"metadata"`
463463}
464464
@@ -978,16 +978,8 @@ func (r *observabilityPipelineResource) Schema(_ context.Context, _ resource.Sch
978978 },
979979 },
980980 Blocks : map [string ]schema.Block {
981- "auth" : schema.SingleNestedBlock {
982- Description : "GCP credentials used to authenticate with Google Cloud Storage." ,
983- Attributes : map [string ]schema.Attribute {
984- "credentials_file" : schema.StringAttribute {
985- Required : true ,
986- Description : "Path to the GCP service account key file." ,
987- },
988- },
989- },
990- "tls" : tlsSchema (),
981+ "auth" : gcpAuthSchema (),
982+ "tls" : tlsSchema (),
991983 },
992984 },
993985 },
@@ -1893,20 +1885,12 @@ func (r *observabilityPipelineResource) Schema(_ context.Context, _ resource.Sch
18931885 Description : "Storage class used for objects stored in GCS." ,
18941886 },
18951887 "acl" : schema.StringAttribute {
1896- Required : true ,
1888+ Optional : true ,
18971889 Description : "Access control list setting for objects written to the bucket." ,
18981890 },
18991891 },
19001892 Blocks : map [string ]schema.Block {
1901- "auth" : schema.SingleNestedBlock {
1902- Description : "GCP credentials used to authenticate with Google Cloud Storage." ,
1903- Attributes : map [string ]schema.Attribute {
1904- "credentials_file" : schema.StringAttribute {
1905- Required : true ,
1906- Description : "Path to the GCP service account key file." ,
1907- },
1908- },
1909- },
1893+ "auth" : gcpAuthSchema (),
19101894 "metadata" : schema.ListNestedBlock {
19111895 Description : "Custom metadata key-value pairs added to each object." ,
19121896 NestedObject : schema.NestedBlockObject {
@@ -1952,16 +1936,8 @@ func (r *observabilityPipelineResource) Schema(_ context.Context, _ resource.Sch
19521936 },
19531937 },
19541938 Blocks : map [string ]schema.Block {
1955- "auth" : schema.SingleNestedBlock {
1956- Description : "GCP credentials used to authenticate with Google Cloud Pub/Sub." ,
1957- Attributes : map [string ]schema.Attribute {
1958- "credentials_file" : schema.StringAttribute {
1959- Optional : true ,
1960- Description : "Path to the GCP service account key file." ,
1961- },
1962- },
1963- },
1964- "tls" : tlsSchema (),
1939+ "auth" : gcpAuthSchema (),
1940+ "tls" : tlsSchema (),
19651941 },
19661942 },
19671943 },
@@ -2265,15 +2241,7 @@ func (r *observabilityPipelineResource) Schema(_ context.Context, _ resource.Sch
22652241 },
22662242 },
22672243 Blocks : map [string ]schema.Block {
2268- "auth" : schema.SingleNestedBlock {
2269- Description : "GCP credentials used to authenticate with Google Cloud Storage." ,
2270- Attributes : map [string ]schema.Attribute {
2271- "credentials_file" : schema.StringAttribute {
2272- Optional : true ,
2273- Description : "Path to the GCP service account key file." ,
2274- },
2275- },
2276- },
2244+ "auth" : gcpAuthSchema (),
22772245 },
22782246 },
22792247 },
@@ -2349,6 +2317,40 @@ func tlsSchema() schema.SingleNestedBlock {
23492317 }
23502318}
23512319
2320+ func gcpAuthSchema () schema.SingleNestedBlock {
2321+ return schema.SingleNestedBlock {
2322+ Description : "GCP credentials used to authenticate with Google Cloud services." ,
2323+ Attributes : map [string ]schema.Attribute {
2324+ "credentials_file" : schema.StringAttribute {
2325+ Optional : true ,
2326+ Description : "Path to the GCP service account key file. Required when `auth` block is specified." ,
2327+ },
2328+ },
2329+ }
2330+ }
2331+
2332+ func expandGcpAuth (auth * gcpAuthModel ) * datadogV2.ObservabilityPipelineGcpAuth {
2333+ if auth == nil {
2334+ return nil
2335+ }
2336+
2337+ gcpAuth := & datadogV2.ObservabilityPipelineGcpAuth {}
2338+ if ! auth .CredentialsFile .IsNull () {
2339+ gcpAuth .SetCredentialsFile (auth .CredentialsFile .ValueString ())
2340+ }
2341+ return gcpAuth
2342+ }
2343+
2344+ func flattenGcpAuth (auth * datadogV2.ObservabilityPipelineGcpAuth ) * gcpAuthModel {
2345+ if auth == nil {
2346+ return nil
2347+ }
2348+
2349+ return & gcpAuthModel {
2350+ CredentialsFile : types .StringValue (auth .CredentialsFile ),
2351+ }
2352+ }
2353+
23522354func (r * observabilityPipelineResource ) ImportState (ctx context.Context , request resource.ImportStateRequest , response * resource.ImportStateResponse ) {
23532355 resource .ImportStatePassthroughID (ctx , frameworkPath .Root ("id" ), request , response )
23542356}
@@ -3534,15 +3536,18 @@ func expandGoogleCloudStorageDestination(ctx context.Context, d *gcsDestinationM
35343536 dest .SetId (d .Id .ValueString ())
35353537 dest .SetBucket (d .Bucket .ValueString ())
35363538 dest .SetStorageClass (datadogV2 .ObservabilityPipelineGoogleCloudStorageDestinationStorageClass (d .StorageClass .ValueString ()))
3537- dest .SetAcl (datadogV2 .ObservabilityPipelineGoogleCloudStorageDestinationAcl (d .Acl .ValueString ()))
3539+
3540+ if ! d .Acl .IsNull () {
3541+ dest .SetAcl (datadogV2 .ObservabilityPipelineGoogleCloudStorageDestinationAcl (d .Acl .ValueString ()))
3542+ }
35383543
35393544 if ! d .KeyPrefix .IsNull () {
35403545 dest .SetKeyPrefix (d .KeyPrefix .ValueString ())
35413546 }
35423547
3543- dest . SetAuth (datadogV2. ObservabilityPipelineGcpAuth {
3544- CredentialsFile : d . Auth . CredentialsFile . ValueString (),
3545- })
3548+ if auth := expandGcpAuth ( d . Auth ); auth != nil {
3549+ dest . SetAuth ( * auth )
3550+ }
35463551
35473552 var metadata []datadogV2.ObservabilityPipelineMetadataEntry
35483553 for _ , m := range d .Metadata {
@@ -3577,18 +3582,24 @@ func flattenGoogleCloudStorageDestination(ctx context.Context, src *datadogV2.Ob
35773582 })
35783583 }
35793584
3580- return & gcsDestinationModel {
3585+ out := & gcsDestinationModel {
35813586 Id : types .StringValue (src .GetId ()),
35823587 Bucket : types .StringValue (src .GetBucket ()),
35833588 KeyPrefix : types .StringPointerValue (src .KeyPrefix ),
35843589 StorageClass : types .StringValue (string (src .GetStorageClass ())),
3585- Acl : types . StringValue ( string ( src . GetAcl ())) ,
3586- Auth : gcpAuthModel {
3587- CredentialsFile : types . StringValue ( src . Auth . CredentialsFile ),
3588- },
3589- Metadata : metadata ,
3590- Inputs : inputs ,
3590+ Metadata : metadata ,
3591+ Inputs : inputs ,
3592+ }
3593+
3594+ if acl , ok := src . GetAclOk (); ok {
3595+ out . Acl = types . StringValue ( string ( * acl ))
35913596 }
3597+
3598+ if auth , ok := src .GetAuthOk (); ok {
3599+ out .Auth = flattenGcpAuth (auth )
3600+ }
3601+
3602+ return out
35923603}
35933604
35943605func expandGooglePubSubDestination (ctx context.Context , d * googlePubSubDestinationModel ) datadogV2.ObservabilityPipelineConfigDestinationItem {
@@ -3601,10 +3612,8 @@ func expandGooglePubSubDestination(ctx context.Context, d *googlePubSubDestinati
36013612 dest .SetEncoding (datadogV2 .ObservabilityPipelineGooglePubSubDestinationEncoding (d .Encoding .ValueString ()))
36023613 }
36033614
3604- if d .Auth != nil {
3605- auth := datadogV2.ObservabilityPipelineGcpAuth {}
3606- auth .SetCredentialsFile (d .Auth .CredentialsFile .ValueString ())
3607- dest .SetAuth (auth )
3615+ if auth := expandGcpAuth (d .Auth ); auth != nil {
3616+ dest .SetAuth (* auth )
36083617 }
36093618
36103619 if d .Tls != nil {
@@ -3639,9 +3648,7 @@ func flattenGooglePubSubDestination(ctx context.Context, src *datadogV2.Observab
36393648 }
36403649
36413650 if auth , ok := src .GetAuthOk (); ok {
3642- out .Auth = & gcpAuthModel {
3643- CredentialsFile : types .StringValue (auth .CredentialsFile ),
3644- }
3651+ out .Auth = flattenGcpAuth (auth )
36453652 }
36463653
36473654 if src .Tls != nil {
@@ -4520,10 +4527,8 @@ func expandGooglePubSubSource(src *googlePubSubSourceModel) datadogV2.Observabil
45204527 pubsub .SetSubscription (src .Subscription .ValueString ())
45214528 pubsub .SetDecoding (datadogV2 .ObservabilityPipelineDecoding (src .Decoding .ValueString ()))
45224529
4523- if src .Auth != nil {
4524- auth := datadogV2.ObservabilityPipelineGcpAuth {}
4525- auth .SetCredentialsFile (src .Auth .CredentialsFile .ValueString ())
4526- pubsub .SetAuth (auth )
4530+ if auth := expandGcpAuth (src .Auth ); auth != nil {
4531+ pubsub .SetAuth (* auth )
45274532 }
45284533
45294534 if src .Tls != nil {
@@ -4546,8 +4551,8 @@ func flattenGooglePubSubSource(src *datadogV2.ObservabilityPipelineGooglePubSubS
45464551 Decoding : types .StringValue (string (src .GetDecoding ())),
45474552 }
45484553
4549- out . Auth = & gcpAuthModel {
4550- CredentialsFile : types . StringValue ( src . Auth . CredentialsFile ),
4554+ if auth , ok := src . GetAuthOk (); ok {
4555+ out . Auth = flattenGcpAuth ( auth )
45514556 }
45524557
45534558 if src .Tls != nil {
@@ -4881,12 +4886,8 @@ func expandGoogleChronicleDestination(ctx context.Context, src *googleChronicleD
48814886 src .Inputs .ElementsAs (ctx , & inputs , false )
48824887 dest .SetInputs (inputs )
48834888
4884- if src .Auth != nil {
4885- auth := datadogV2.ObservabilityPipelineGcpAuth {}
4886- if ! src .Auth .CredentialsFile .IsNull () {
4887- auth .SetCredentialsFile (src .Auth .CredentialsFile .ValueString ())
4888- }
4889- dest .Auth = auth
4889+ if auth := expandGcpAuth (src .Auth ); auth != nil {
4890+ dest .SetAuth (* auth )
48904891 }
48914892
48924893 if ! src .CustomerId .IsNull () {
@@ -4919,8 +4920,8 @@ func flattenGoogleChronicleDestination(ctx context.Context, src *datadogV2.Obser
49194920 LogType : types .StringValue (src .GetLogType ()),
49204921 }
49214922
4922- out . Auth = & gcpAuthModel {
4923- CredentialsFile : types . StringValue ( src . Auth . CredentialsFile ),
4923+ if auth , ok := src . GetAuthOk (); ok {
4924+ out . Auth = flattenGcpAuth ( auth )
49244925 }
49254926
49264927 return out
0 commit comments