Skip to content

Commit 1ed9047

Browse files
committed
CDPCP-14609 - Type conversion issue from int64 and int32 for AWS DL
1 parent 0b20a3f commit 1ed9047

File tree

6 files changed

+156
-215
lines changed

6 files changed

+156
-215
lines changed

docs/resources/environments_azure_environment.md

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,56 +22,54 @@ The environment is a logical entity that represents the association of your user
2222
# OF ANY KIND, either express or implied. Refer to the License for the specific
2323
# permissions and limitations governing your use of the file.
2424
25-
terraform {
26-
required_providers {
27-
cdp = {
28-
source = "cloudera/cdp"
29-
}
25+
resource "cdp_environments_azure_credential" "example-cred" {
26+
credential_name = "example-cdp-azure-credential"
27+
subscription_id = "<value>"
28+
tenant_id = "<value>"
29+
app_based = {
30+
application_id = "<value>"
31+
secret_key = "<value>"
3032
}
33+
description = "Example Azure Credential"
3134
}
3235
33-
provider "cdp" {
34-
cdp_profile = "mowdev"
35-
cdp_endpoint_url = "https://cloudera.dps.mow-dev.cloudera.com"
36-
cdp_config_file = "/Users/gmeszaros/.cdp/config"
37-
cdp_shared_credentials_file = "/Users/gmeszaros/.cdp/credentials"
38-
local_environment = false
39-
}
40-
41-
resource "cdp_environments_azure_environment" "my-azure-environment-flexible" {
42-
environment_name = "gmeszaros-tf-env-2"
43-
credential_name = "dszabo-az-cred"
44-
region = "westus2"
36+
resource "cdp_environments_azure_environment" "example-env" {
37+
environment_name = "example-cdp-azure-environment"
38+
credential_name = cdp_environments_azure_credential.example-cred.credential_name
39+
region = "<your-region>"
4540
security_access = {
4641
cidr = "0.0.0.0/0"
4742
}
4843
existing_network_params = {
49-
resource_group_name = "cloud-daily"
50-
network_id = "cloud-daily"
51-
subnet_ids = ["cloud-daily.internal.0.westus2", "cloud-daily.internal.1.westus2"]
52-
flexible_server_subnet_ids = ["subnet_10_124_116_0-23"]
53-
database_private_dns_zone_id = "/subscriptions/3ddda1c7-d1f5-4e7b-ac81-0523f483b3b3/resourceGroups/cloud-daily/providers/Microsoft.Network/privateDnsZones/flexible.cloud-daily.postgres.database.azure.com"
44+
network_id = "network-name"
45+
resource_group_name = "rg-name"
46+
subnet_ids = ["<env-subnet-1>", "<env-subnet-2>", "<env-subnet-3>"]
5447
}
55-
resource_group_name = "dszabo-cdp"
56-
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCoACV6cXVqQskr4NPhlmR/rQ40p7xOGgKG3kS2GR0+iU3N5hK6NeK1AWecb9FxfiSSAS3Z9Nxpx/Ktq8PHWgIa5gsnHMHRvU5pPHHIQQbUc6/Ju7hxfX+t/rgX5y0q7o1UrT+m4HTP3bQESNg5ggRFnvgKeZtZf6xOpCh37ij4k2Whcc6K8z2nTPa+pRAjmYiYvxlGnOv3ga4yQyID35NuBnIOqZQPn3mVoIw60klUNbJ45l5gsr/hPHAMqO2+TnTNpajU0tecQED8iFlgR7293PSkwb94sPelQbey1Kr5s8WozqsAyA99kEpr91KHNYb9KhVC5E/Roxfx5R9+PxK1WCdx3cTiwc2NSrd+nQwc/DeE9DPqrZxmiHSnWxtRFnneh1H+I8pf/YDndTdHziHxoTz/IQ94pgKKX4yC+j2TRa4yvETtTVXfIilVjJtswXbpOwA2MSiU+a7y6tdhOyq3hhdLS49kiNNqH1ILnQ0PoEK9RchRPjtoFFUd10N5+20= cloudbreak"
48+
public_key = "my-key"
5749
log_storage = {
58-
managed_identity = "/subscriptions/3ddda1c7-d1f5-4e7b-ac81-0523f483b3b3/resourcegroups/dszabo-cdp/providers/Microsoft.ManagedIdentity/userAssignedIdentities/dszabo-logger"
59-
storage_location_base = "abfs://dszabocdpfs@dszabocdpstorage.dfs.core.windows.net"
60-
}
61-
use_public_ip = false
62-
enable_outbound_load_balancer = true
63-
encryption_at_host = true
64-
freeipa = {
65-
instance_count_by_group = 2
66-
os = "centos7"
50+
storage_location_base = "abfs://rgname-fs@rgname-storage.dfs.core.windows.net"
51+
managed_identity = "/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourcegroups/my-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/logger"
6752
}
68-
tags = {
69-
"made-with" : "CDP Terraform Provider"
53+
resource_group_name = "rg-name"
54+
encryption_user_managed_identity = "some-identity"
55+
use_public_ip = true
56+
compute_cluster = {
57+
enabled = false
58+
configuration = {
59+
private_cluster = false
60+
outbound_type = "udr"
61+
kube_api_authorized_ip_ranges = ["0.0.0.0/0"]
62+
worker_node_subnets = ["<env-subnet-1>", "<env-subnet-2>", "<env-subnet-3>"]
63+
}
7064
}
7165
}
7266
67+
output "credential" {
68+
value = cdp_environments_azure_credential.example-cred
69+
}
70+
7371
output "environment" {
74-
value = cdp_environments_azure_environment.my-azure-environment-flexible
72+
value = cdp_environments_azure_environment.example-env
7573
}
7674
```
7775

examples/resources/cdp_environments_azure_environment/resource.tf

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,52 @@
88
# OF ANY KIND, either express or implied. Refer to the License for the specific
99
# permissions and limitations governing your use of the file.
1010

11-
terraform {
12-
required_providers {
13-
cdp = {
14-
source = "cloudera/cdp"
15-
}
11+
resource "cdp_environments_azure_credential" "example-cred" {
12+
credential_name = "example-cdp-azure-credential"
13+
subscription_id = "<value>"
14+
tenant_id = "<value>"
15+
app_based = {
16+
application_id = "<value>"
17+
secret_key = "<value>"
1618
}
19+
description = "Example Azure Credential"
1720
}
1821

19-
provider "cdp" {
20-
cdp_profile = "mowdev"
21-
cdp_endpoint_url = "https://cloudera.dps.mow-dev.cloudera.com"
22-
cdp_config_file = "/Users/gmeszaros/.cdp/config"
23-
cdp_shared_credentials_file = "/Users/gmeszaros/.cdp/credentials"
24-
local_environment = false
25-
}
26-
27-
resource "cdp_environments_azure_environment" "my-azure-environment-flexible" {
28-
environment_name = "gmeszaros-tf-env-2"
29-
credential_name = "dszabo-az-cred"
30-
region = "westus2"
22+
resource "cdp_environments_azure_environment" "example-env" {
23+
environment_name = "example-cdp-azure-environment"
24+
credential_name = cdp_environments_azure_credential.example-cred.credential_name
25+
region = "<your-region>"
3126
security_access = {
3227
cidr = "0.0.0.0/0"
3328
}
3429
existing_network_params = {
35-
resource_group_name = "cloud-daily"
36-
network_id = "cloud-daily"
37-
subnet_ids = ["cloud-daily.internal.0.westus2", "cloud-daily.internal.1.westus2"]
38-
flexible_server_subnet_ids = ["subnet_10_124_116_0-23"]
39-
database_private_dns_zone_id = "/subscriptions/3ddda1c7-d1f5-4e7b-ac81-0523f483b3b3/resourceGroups/cloud-daily/providers/Microsoft.Network/privateDnsZones/flexible.cloud-daily.postgres.database.azure.com"
30+
network_id = "network-name"
31+
resource_group_name = "rg-name"
32+
subnet_ids = ["<env-subnet-1>", "<env-subnet-2>", "<env-subnet-3>"]
4033
}
41-
resource_group_name = "dszabo-cdp"
42-
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCoACV6cXVqQskr4NPhlmR/rQ40p7xOGgKG3kS2GR0+iU3N5hK6NeK1AWecb9FxfiSSAS3Z9Nxpx/Ktq8PHWgIa5gsnHMHRvU5pPHHIQQbUc6/Ju7hxfX+t/rgX5y0q7o1UrT+m4HTP3bQESNg5ggRFnvgKeZtZf6xOpCh37ij4k2Whcc6K8z2nTPa+pRAjmYiYvxlGnOv3ga4yQyID35NuBnIOqZQPn3mVoIw60klUNbJ45l5gsr/hPHAMqO2+TnTNpajU0tecQED8iFlgR7293PSkwb94sPelQbey1Kr5s8WozqsAyA99kEpr91KHNYb9KhVC5E/Roxfx5R9+PxK1WCdx3cTiwc2NSrd+nQwc/DeE9DPqrZxmiHSnWxtRFnneh1H+I8pf/YDndTdHziHxoTz/IQ94pgKKX4yC+j2TRa4yvETtTVXfIilVjJtswXbpOwA2MSiU+a7y6tdhOyq3hhdLS49kiNNqH1ILnQ0PoEK9RchRPjtoFFUd10N5+20= cloudbreak"
34+
public_key = "my-key"
4335
log_storage = {
44-
managed_identity = "/subscriptions/3ddda1c7-d1f5-4e7b-ac81-0523f483b3b3/resourcegroups/dszabo-cdp/providers/Microsoft.ManagedIdentity/userAssignedIdentities/dszabo-logger"
45-
storage_location_base = "abfs://dszabocdpfs@dszabocdpstorage.dfs.core.windows.net"
46-
}
47-
use_public_ip = false
48-
enable_outbound_load_balancer = true
49-
encryption_at_host = true
50-
freeipa = {
51-
instance_count_by_group = 2
52-
os = "centos7"
36+
storage_location_base = "abfs://rgname-fs@rgname-storage.dfs.core.windows.net"
37+
managed_identity = "/subscriptions/123e4567-e89b-12d3-a456-426614174000/resourcegroups/my-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/logger"
5338
}
54-
tags = {
55-
"made-with" : "CDP Terraform Provider"
39+
resource_group_name = "rg-name"
40+
encryption_user_managed_identity = "some-identity"
41+
use_public_ip = true
42+
compute_cluster = {
43+
enabled = false
44+
configuration = {
45+
private_cluster = false
46+
outbound_type = "udr"
47+
kube_api_authorized_ip_ranges = ["0.0.0.0/0"]
48+
worker_node_subnets = ["<env-subnet-1>", "<env-subnet-2>", "<env-subnet-3>"]
49+
}
5650
}
5751
}
5852

53+
output "credential" {
54+
value = cdp_environments_azure_credential.example-cred
55+
}
56+
5957
output "environment" {
60-
value = cdp_environments_azure_environment.my-azure-environment-flexible
61-
}
58+
value = cdp_environments_azure_environment.example-env
59+
}

resources/datalake/resource_aws_datalake.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ func (r *awsDatalakeResource) Metadata(_ context.Context, req resource.MetadataR
5353
resp.TypeName = req.ProviderTypeName + "_datalake_aws_datalake"
5454
}
5555

56-
func (r *awsDatalakeResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
57-
resp.Schema = awsDatalakeResourceSchema
58-
}
59-
6056
func (r *awsDatalakeResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
6157
r.client = utils.GetCdpClientForResource(req, resp)
6258
}

resources/datalake/schema_aws_datalake.go

Lines changed: 16 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -11,156 +11,35 @@
1111
package datalake
1212

1313
import (
14+
"context"
15+
16+
"github.com/hashicorp/terraform-plugin-framework/resource"
1417
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
15-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
16-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
17-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default"
1818
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
1919
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
20-
"github.com/hashicorp/terraform-plugin-framework/types"
20+
21+
"github.com/cloudera/terraform-provider-cdp/utils"
2122
)
2223

23-
var awsDatalakeResourceSchema = schema.Schema{
24-
MarkdownDescription: "A Data Lake is a service which provides a protective ring around the data stored in a cloud object store, including authentication, authorization, and governance support.",
25-
Attributes: map[string]schema.Attribute{
26-
"id": schema.StringAttribute{
27-
Computed: true,
28-
PlanModifiers: []planmodifier.String{
29-
stringplanmodifier.UseStateForUnknown(),
30-
},
31-
},
32-
"polling_options": schema.SingleNestedAttribute{
33-
MarkdownDescription: "Polling related configuration options that could specify various values that will be used during CDP resource creation.",
34-
Optional: true,
35-
Attributes: map[string]schema.Attribute{
36-
"async": schema.BoolAttribute{
37-
MarkdownDescription: "Boolean value that specifies if Terraform should wait for resource creation/deletion.",
38-
Optional: true,
39-
Computed: true,
40-
Default: booldefault.StaticBool(false),
41-
PlanModifiers: []planmodifier.Bool{
42-
boolplanmodifier.UseStateForUnknown(),
43-
},
44-
},
45-
"polling_timeout": schema.Int64Attribute{
46-
MarkdownDescription: "Timeout value in minutes that specifies for how long should the polling go for resource creation/deletion.",
47-
Default: int64default.StaticInt64(90),
48-
Computed: true,
49-
Optional: true,
50-
},
51-
"call_failure_threshold": schema.Int64Attribute{
52-
MarkdownDescription: "Threshold value that specifies how many times should a single call failure happen before giving up the polling.",
53-
Default: int64default.StaticInt64(3),
54-
Computed: true,
55-
Optional: true,
56-
},
57-
},
58-
},
59-
"instance_profile": schema.StringAttribute{
60-
Required: true,
61-
},
62-
"storage_location_base": schema.StringAttribute{
63-
Required: true,
64-
},
24+
func (r *awsDatalakeResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
25+
attr := map[string]schema.Attribute{}
26+
utils.Append(attr, generalAttributes)
27+
utils.Append(attr, map[string]schema.Attribute{
6528
"certificate_expiration_state": schema.StringAttribute{
6629
Computed: true,
6730
PlanModifiers: []planmodifier.String{
6831
stringplanmodifier.UseStateForUnknown(),
6932
},
7033
},
71-
"creation_date": schema.StringAttribute{
72-
Computed: true,
73-
PlanModifiers: []planmodifier.String{
74-
stringplanmodifier.UseStateForUnknown(),
75-
},
76-
},
77-
"crn": schema.StringAttribute{
78-
Computed: true,
79-
PlanModifiers: []planmodifier.String{
80-
stringplanmodifier.UseStateForUnknown(),
81-
},
82-
},
83-
"datalake_name": schema.StringAttribute{
34+
"storage_location_base": schema.StringAttribute{
8435
Required: true,
8536
},
86-
"enable_ranger_raz": schema.BoolAttribute{
87-
Optional: true,
88-
Computed: true,
89-
PlanModifiers: []planmodifier.Bool{
90-
boolplanmodifier.UseStateForUnknown(),
91-
},
92-
},
93-
"environment_crn": schema.StringAttribute{
94-
Computed: true,
95-
PlanModifiers: []planmodifier.String{
96-
stringplanmodifier.UseStateForUnknown(),
97-
},
98-
},
99-
"environment_name": schema.StringAttribute{
37+
"instance_profile": schema.StringAttribute{
10038
Required: true,
10139
},
102-
"image": schema.SingleNestedAttribute{
103-
Optional: true,
104-
Attributes: map[string]schema.Attribute{
105-
"catalog_name": schema.StringAttribute{
106-
Optional: true,
107-
},
108-
"id": schema.StringAttribute{
109-
Optional: true,
110-
},
111-
"os": schema.StringAttribute{
112-
Optional: true,
113-
},
114-
},
115-
},
116-
"java_version": schema.Int64Attribute{
117-
Optional: true,
118-
},
119-
"multi_az": schema.BoolAttribute{
120-
Optional: true,
121-
Computed: true,
122-
PlanModifiers: []planmodifier.Bool{
123-
boolplanmodifier.UseStateForUnknown(),
124-
},
125-
},
126-
"recipes": schema.SetNestedAttribute{
127-
Optional: true,
128-
NestedObject: schema.NestedAttributeObject{
129-
Attributes: map[string]schema.Attribute{
130-
"instance_group_name": schema.StringAttribute{
131-
MarkdownDescription: "The name of the designated instance group.",
132-
Required: true,
133-
},
134-
"recipe_names": schema.SetAttribute{
135-
MarkdownDescription: "The set of recipe names that are going to be applied on the given instance group.",
136-
ElementType: types.StringType,
137-
Required: true,
138-
},
139-
},
140-
},
141-
},
142-
"runtime": schema.StringAttribute{
143-
Optional: true,
144-
},
145-
"scale": schema.StringAttribute{
146-
Computed: true,
147-
Optional: true,
148-
},
149-
"status": schema.StringAttribute{
150-
Computed: true,
151-
PlanModifiers: []planmodifier.String{
152-
stringplanmodifier.UseStateForUnknown(),
153-
},
154-
},
155-
"status_reason": schema.StringAttribute{
156-
Computed: true,
157-
PlanModifiers: []planmodifier.String{
158-
stringplanmodifier.UseStateForUnknown(),
159-
},
160-
},
161-
"tags": schema.MapAttribute{
162-
Optional: true,
163-
ElementType: types.StringType,
164-
},
165-
},
40+
})
41+
resp.Schema = schema.Schema{
42+
MarkdownDescription: "A Data Lake is a service which provides a protective ring around the data stored in a cloud object store, including authentication, authorization, and governance support.",
43+
Attributes: attr,
44+
}
16645
}

0 commit comments

Comments
 (0)