-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CDPCP-9785 - extend credential prerequisites with policy JSONs
- Loading branch information
Showing
3 changed files
with
94 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
resources/environments/model_aws_credential_prerequisites.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2024 Cloudera. All Rights Reserved. | ||
// | ||
// This file is licensed under the Apache License Version 2.0 (the "License"). | ||
// You may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
// OF ANY KIND, either express or implied. Refer to the License for the specific | ||
// permissions and limitations governing your use of the file. | ||
|
||
package environments | ||
|
||
import "github.com/hashicorp/terraform-plugin-framework/types" | ||
|
||
type awsCredentialPrerequisitesDataSourceModel struct { | ||
ID types.String `tfsdk:"id"` | ||
AccountID types.String `tfsdk:"account_id"` | ||
ExternalID types.String `tfsdk:"external_id"` | ||
Policy types.String `tfsdk:"policy"` | ||
Policies []*credentialGranularPolicyDataSourceModel `tfsdk:"policies"` | ||
} | ||
|
||
type credentialGranularPolicyDataSourceModel struct { | ||
Service types.String `tfsdk:"service"` | ||
PolicyJson types.String `tfsdk:"policy_json"` | ||
} |
56 changes: 56 additions & 0 deletions
56
resources/environments/schema_aws_credential_prerequisites.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2024 Cloudera. All Rights Reserved. | ||
// | ||
// This file is licensed under the Apache License Version 2.0 (the "License"). | ||
// You may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
// OF ANY KIND, either express or implied. Refer to the License for the specific | ||
// permissions and limitations governing your use of the file. | ||
|
||
package environments | ||
|
||
import ( | ||
"context" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource/schema" | ||
) | ||
|
||
func (d *awsCredentialPrerequisitesDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { | ||
resp.Schema = schema.Schema{ | ||
MarkdownDescription: "This data source is used to get information required to set up a delegated access role in AWS that can be used to create a CDP credential.", | ||
Attributes: map[string]schema.Attribute{ | ||
"id": schema.StringAttribute{ | ||
Computed: true, | ||
}, | ||
"account_id": schema.StringAttribute{ | ||
MarkdownDescription: "The AWS account ID of the identity used by CDP when assuming a delegated access role associated with a CDP credential.", | ||
Computed: true, | ||
}, | ||
"external_id": schema.StringAttribute{ | ||
MarkdownDescription: "The external ID that will be used when assuming a delegated access role associated with a CDP credential.", | ||
Computed: true, | ||
}, | ||
"policy": schema.StringAttribute{ | ||
MarkdownDescription: "The related policy json encoded in base64", | ||
Computed: true, | ||
}, | ||
"policies": schema.SetNestedAttribute{ | ||
Computed: true, | ||
MarkdownDescription: "The fine-grained policies related to each service.", | ||
NestedObject: schema.NestedAttributeObject{ | ||
Attributes: map[string]schema.Attribute{ | ||
"service": schema.StringAttribute{ | ||
Computed: true, | ||
MarkdownDescription: "The name of the service that requires the given policy for resource management.", | ||
}, | ||
"policy_json": schema.StringAttribute{ | ||
Computed: true, | ||
MarkdownDescription: "The policy JSON encoded in base64.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |