Skip to content

Commit 2c6ee84

Browse files
authored
Add vpc peered flag (#640)
1 parent e928019 commit 2c6ee84

File tree

10 files changed

+89
-16
lines changed

10 files changed

+89
-16
lines changed

castai/resource_commitments_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func TestCommitmentsResourceCreateAndUpdate(t *testing.T) {
100100
Cpu: lo.ToPtr("10"),
101101
CudId: lo.ToPtr("123456789"),
102102
MemoryMb: lo.ToPtr("20480"),
103-
Plan: lo.ToPtr(sdk.TWELVEMONTH),
103+
Plan: lo.ToPtr(sdk.CastaiInventoryV1beta1GCPResourceCUDCUDPlanTWELVEMONTH),
104104
Status: lo.ToPtr("Active"),
105105
Type: lo.ToPtr("COMPUTE_OPTIMIZED_C2D"),
106106
},

castai/resource_edge_location.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type awsModel struct {
5959
AccessKeyIDWO types.String `tfsdk:"access_key_id_wo"`
6060
SecretAccessKeyWO types.String `tfsdk:"secret_access_key_wo"`
6161
VpcID types.String `tfsdk:"vpc_id"`
62+
VpcPeered types.Bool `tfsdk:"vpc_peered"`
6263
SecurityGroupID types.String `tfsdk:"security_group_id"`
6364
SubnetIDs types.Map `tfsdk:"subnet_ids"`
6465
// Deprecated. Should be removed with name_tag attribute removal.
@@ -94,6 +95,7 @@ func (m awsModel) Equal(other *awsModel) bool {
9495
}
9596
return m.AccountID.Equal(other.AccountID) &&
9697
m.VpcID.Equal(other.VpcID) &&
98+
m.VpcPeered.Equal(other.VpcPeered) &&
9799
m.SecurityGroupID.Equal(other.SecurityGroupID) &&
98100
m.SubnetIDs.Equal(other.SubnetIDs)
99101
}
@@ -239,6 +241,10 @@ func (r *edgeLocationResource) Schema(_ context.Context, _ resource.SchemaReques
239241
Required: true,
240242
Description: "VPC ID to be used in the selected region",
241243
},
244+
"vpc_peered": schema.BoolAttribute{
245+
Optional: true,
246+
Description: "Whether existing VPC is peered with main cluster's VPC. Field is ignored if vpc_id is not provided or main cluster is not EKS",
247+
},
242248
"security_group_id": schema.StringAttribute{
243249
Required: true,
244250
Description: "Security group ID to be used in the selected region",
@@ -690,6 +696,7 @@ func (r *edgeLocationResource) toAWS(ctx context.Context, plan, config *awsModel
690696
},
691697
Networking: &omni.AWSParamAWSNetworking{
692698
VpcId: plan.VpcID.ValueString(),
699+
VpcPeered: plan.VpcPeered.ValueBoolPointer(),
693700
SecurityGroupId: plan.SecurityGroupID.ValueString(),
694701
SubnetIds: subnetMap,
695702
},
@@ -711,6 +718,7 @@ func (r *edgeLocationResource) toAWSModel(ctx context.Context, config *omni.AWSP
711718
AccountID: types.StringValue(lo.FromPtr(config.AccountId)),
712719
VpcID: types.StringNull(),
713720
SecurityGroupID: types.StringNull(),
721+
VpcPeered: types.BoolNull(),
714722
SubnetIDs: types.MapNull(types.StringType),
715723
NameTag: types.StringNull(),
716724
AccessKeyIDWO: types.StringNull(),
@@ -719,6 +727,7 @@ func (r *edgeLocationResource) toAWSModel(ctx context.Context, config *omni.AWSP
719727

720728
if config.Networking != nil {
721729
aws.VpcID = types.StringValue(config.Networking.VpcId)
730+
aws.VpcPeered = types.BoolPointerValue(config.Networking.VpcPeered)
722731
aws.SecurityGroupID = types.StringValue(config.Networking.SecurityGroupId)
723732
if config.Networking.NameTag != nil && *config.Networking.NameTag != "" {
724733
aws.NameTag = types.StringValue(*config.Networking.NameTag)

castai/resource_edge_location_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func TestAccCloudAgnostic_ResourceEdgeLocationAWS(t *testing.T) {
3535
resource.TestCheckResourceAttr(resourceName, "zones.1.name", "us-east-1b"),
3636
resource.TestCheckResourceAttrSet(resourceName, "aws.account_id"),
3737
resource.TestCheckResourceAttrSet(resourceName, "aws.vpc_id"),
38+
resource.TestCheckResourceAttrSet(resourceName, "aws.vpc_peered"),
3839
resource.TestCheckResourceAttrSet(resourceName, "aws.security_group_id"),
3940
resource.TestCheckResourceAttr(resourceName, "aws.subnet_ids.%", "2"),
4041
resource.TestCheckResourceAttrSet(resourceName, "id"),
@@ -217,6 +218,7 @@ resource "castai_edge_location" "test" {
217218
account_id = "123456789012"
218219
%[6]s
219220
vpc_id = "vpc-12345678"
221+
vpc_peered = true
220222
security_group_id = "sg-12345678"
221223
subnet_ids = {%[4]s
222224
}

castai/resource_node_configuration_eks_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestAccEKS_ResourceNodeConfiguration(t *testing.T) {
4646
resource.TestCheckResourceAttr(resourceName, "eks.0.volume_throughput", "131"),
4747
resource.TestCheckResourceAttr(resourceName, "eks.0.imds_v1", "true"),
4848
resource.TestCheckResourceAttr(resourceName, "eks.0.imds_hop_limit", "3"),
49-
resource.TestCheckResourceAttr(resourceName, "eks.0.volume_kms_key_arn", "arn:aws:kms:eu-central-1:012345:key/1d989ee1-59cd-4238-8018-79bae29d1109"),
49+
resource.TestCheckResourceAttr(resourceName, "eks.0.volume_kms_key_arn", "arn:aws:kms:us-east-1:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab"),
5050
resource.TestCheckResourceAttr(resourceName, "eks.0.target_group.#", "1"),
5151
resource.TestCheckResourceAttr(resourceName, "eks.0.max_pods_per_node_formula", "NUM_IP_PER_PREFIX-NUM_MAX_NET_INTERFACES"),
5252
resource.TestCheckResourceAttr(resourceName, "eks.0.ips_per_prefix", "4"),
@@ -138,7 +138,7 @@ resource "castai_node_configuration" "test" {
138138
volume_type = "gp3"
139139
volume_iops = 3100
140140
volume_throughput = 131
141-
volume_kms_key_arn = "arn:aws:kms:eu-central-1:012345:key/1d989ee1-59cd-4238-8018-79bae29d1109"
141+
volume_kms_key_arn = "arn:aws:kms:us-east-1:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab"
142142
imds_v1 = true
143143
imds_hop_limit = 3
144144
max_pods_per_node_formula = "NUM_IP_PER_PREFIX-NUM_MAX_NET_INTERFACES"

castai/resource_node_template_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,7 @@ resource "castai_edge_location" "test_1" {
10161016
secret_access_key_wo = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
10171017
vpc_id = "vpc-12345678"
10181018
security_group_id = "sg-12345678"
1019+
vpc_peered = false
10191020
subnet_ids = {
10201021
"us-east-1a" = "subnet-12345678"
10211022
"us-east-1b" = "subnet-12345679"
@@ -1044,6 +1045,7 @@ resource "castai_edge_location" "test_2" {
10441045
secret_access_key_wo = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
10451046
vpc_id = "vpc-87654321"
10461047
security_group_id = "sg-87654321"
1048+
vpc_peered = false
10471049
subnet_ids = {
10481050
"us-west-2a" = "subnet-87654321"
10491051
}

castai/sdk/api.gen.go

Lines changed: 41 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

castai/sdk/client.gen.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

castai/sdk/omni/api.gen.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

castai/sdk/organization_management/api.gen.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/resources/edge_location.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)