Skip to content

Commit

Permalink
[fix]: [CDS-85006]: add support for region field in aws connector (#806)
Browse files Browse the repository at this point in the history
* add support for region field in aws connector

* updated go sdk

* updated go sdk

* updated go sdk

* updated go sdk
  • Loading branch information
PragyeshMishra01 authored Dec 11, 2023
1 parent d55c04c commit dfc8eb7
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .changelog/806.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/harness_platform_connector_aws - Added support to add aws region field in connector to perform connection test.
```
5 changes: 5 additions & 0 deletions docs/data-sources/platform_connector_aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ data "harness_platform_connector_aws" "example" {
- `inherit_from_delegate` (List of Object) Inherit credentials from the delegate. (see [below for nested schema](#nestedatt--inherit_from_delegate))
- `irsa` (List of Object) Use IAM role for service accounts. (see [below for nested schema](#nestedatt--irsa))
- `manual` (List of Object) Use IAM role for service accounts. (see [below for nested schema](#nestedatt--manual))
- `region` AWS Region to perform Connection test of Connector.
- `tags` (Set of String) Tags to associate with the resource.

<a id="nestedatt--cross_account_access"></a>
Expand Down Expand Up @@ -88,6 +89,7 @@ Read-Only:
Read-Only:

- `delegate_selectors` (Set of String) The delegates to inherit the credentials from.
- `region` AWS Region to perform Connection test of Connector.


<a id="nestedatt--irsa"></a>
Expand All @@ -96,6 +98,7 @@ Read-Only:
Read-Only:

- `delegate_selectors` (Set of String) The delegates to inherit the credentials from.
- `region` AWS Region to perform Connection test of Connector.


<a id="nestedatt--manual"></a>
Expand All @@ -107,5 +110,7 @@ Read-Only:
- `access_key_ref` (String) Reference to the Harness secret containing the aws access key. To reference a secret at the organization scope, prefix 'org' to the expression: org.{identifier}. To reference a secret at the account scope, prefix 'account` to the expression: account.{identifier}.
- `delegate_selectors` (Set of String) Connect only use delegates with these tags.
- `secret_key_ref` (String) Reference to the Harness secret containing the aws secret key. To reference a secret at the organization scope, prefix 'org' to the expression: org.{identifier}. To reference a secret at the account scope, prefix 'account` to the expression: account.{identifier}.
- `region` AWS Region to perform Connection test of Connector.



13 changes: 13 additions & 0 deletions docs/resources/platform_connector_aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ resource "harness_platform_connector_aws" "aws" {
access_key_ref = "account.access_id"
secret_key_ref = "account.secret_id"
delegate_selectors = ["harness-delegate"]
region = "aws_region"
}
}
Expand All @@ -40,6 +41,7 @@ resource "harness_platform_connector_aws" "aws" {
access_key_ref = "account.access_id"
secret_key_ref = "account.secret_id"
delegate_selectors = ["harness-delegate"]
region = "aws_region"
}
equal_jitter_backoff_strategy {
base_delay = 10
Expand All @@ -60,6 +62,7 @@ resource "harness_platform_connector_aws" "aws" {
access_key_ref = "account.access_id"
secret_key_ref = "account.secret_id"
delegate_selectors = ["harness-delegate"]
region = "aws_region"
}
full_jitter_backoff_strategy {
base_delay = 10
Expand All @@ -80,6 +83,7 @@ resource "harness_platform_connector_aws" "aws" {
access_key_ref = "account.access_id"
secret_key_ref = "account.secret_id"
delegate_selectors = ["harness-delegate"]
region = "aws_region"
}
fixed_delay_backoff_strategy {
fixed_backoff = 10
Expand Down Expand Up @@ -163,6 +167,10 @@ Required:

- `delegate_selectors` (Set of String) The delegates to inherit the credentials from.

Optional:

- `region` (String) Test Region to perform Connection test of AWS Connector.


<a id="nestedblock--irsa"></a>
### Nested Schema for `irsa`
Expand All @@ -171,6 +179,10 @@ Required:

- `delegate_selectors` (Set of String) The delegates to inherit the credentials from.

Optional:

- `region` (String) Test Region to perform Connection test of AWS Connector.


<a id="nestedblock--manual"></a>
### Nested Schema for `manual`
Expand All @@ -184,6 +196,7 @@ Optional:
- `access_key` (String) AWS access key.
- `access_key_ref` (String) Reference to the Harness secret containing the aws access key. To reference a secret at the organization scope, prefix 'org' to the expression: org.{identifier}. To reference a secret at the account scope, prefix 'account` to the expression: account.{identifier}.
- `delegate_selectors` (Set of String) Connect only use delegates with these tags.
- `region` (String) Test Region to perform Connection test of AWS Connector.

## Import

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/antihax/optional v1.0.0
github.com/aws/aws-sdk-go v1.46.4
github.com/docker/docker v24.0.5+incompatible
github.com/harness/harness-go-sdk v0.3.65
github.com/harness/harness-go-sdk v0.3.66
github.com/harness/harness-openapi-go-client v0.0.19
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
Expand Down
10 changes: 2 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,8 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/harness/harness-go-sdk v0.3.59 h1:l2aDHzLiWdHy48onBE5iZeclEYMPtHhlsz8iAtgreBg=
github.com/harness/harness-go-sdk v0.3.59/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-go-sdk v0.3.61 h1:r5UDIkv+ugi4c8hraMJTPPbBgcd5epevg2rxvvI9ANc=
github.com/harness/harness-go-sdk v0.3.61/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-go-sdk v0.3.64 h1:+wHgDjJSxPI8P2W2JyNkjdaz+g3nZY2cud24wwqYcVI=
github.com/harness/harness-go-sdk v0.3.64/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-go-sdk v0.3.65 h1:7r0yGKv0OscDGP+mEUGiCkjdZJLZJSwCDjHSF6K04IQ=
github.com/harness/harness-go-sdk v0.3.65/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-go-sdk v0.3.66 h1:Vrfh8k3yE0kXUWX6lIsupuSR5LAwaNEKD9RRtzVkxnI=
github.com/harness/harness-go-sdk v0.3.66/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-openapi-go-client v0.0.19 h1:8XuZvSPZrNqKRLh7Qksdz78WvRMRzRf88LgzxoT5u7k=
github.com/harness/harness-openapi-go-client v0.0.19/go.mod h1:u0vqYb994BJGotmEwJevF4L3BNAdU9i8ui2d22gmLPA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down
30 changes: 30 additions & 0 deletions internal/service/platform/connector/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ func ResourceConnectorAws() *schema.Resource {
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"region": {
Description: "Test Region to perform Connection test of AWS Connector" + secret_ref_text,
Type: schema.TypeString,
Optional: true,
},
},
},
},
Expand All @@ -87,6 +92,11 @@ func ResourceConnectorAws() *schema.Resource {
Required: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"region": {
Description: "Test Region to perform Connection test of AWS Connector" + secret_ref_text,
Type: schema.TypeString,
Optional: true,
},
},
},
},
Expand All @@ -112,6 +122,11 @@ func ResourceConnectorAws() *schema.Resource {
Required: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"region": {
Description: "Test Region to perform Connection test of AWS Connector" + secret_ref_text,
Type: schema.TypeString,
Optional: true,
},
},
},
},
Expand Down Expand Up @@ -291,6 +306,10 @@ func buildConnectorAws(d *schema.ResourceData) *nextgen.ConnectorInfo {
if attr := config["delegate_selectors"].(*schema.Set).List(); len(attr) > 0 {
connector.Aws.DelegateSelectors = utils.InterfaceSliceToStringSlice(attr)
}

if attr := config["region"].(string); attr != "" {
connector.Aws.Credential.Region = attr
}
}

if attr, ok := d.GetOk("irsa"); ok {
Expand All @@ -300,6 +319,10 @@ func buildConnectorAws(d *schema.ResourceData) *nextgen.ConnectorInfo {
if attr := config["delegate_selectors"].(*schema.Set).List(); len(attr) > 0 {
connector.Aws.DelegateSelectors = utils.InterfaceSliceToStringSlice(attr)
}

if attr := config["region"].(string); attr != "" {
connector.Aws.Credential.Region = attr
}
}

if attr, ok := d.GetOk("inherit_from_delegate"); ok {
Expand All @@ -309,6 +332,10 @@ func buildConnectorAws(d *schema.ResourceData) *nextgen.ConnectorInfo {
if attr := config["delegate_selectors"].(*schema.Set).List(); len(attr) > 0 {
connector.Aws.DelegateSelectors = utils.InterfaceSliceToStringSlice(attr)
}

if attr := config["region"].(string); attr != "" {
connector.Aws.Credential.Region = attr
}
}

if attr, ok := d.GetOk("cross_account_access"); ok {
Expand Down Expand Up @@ -384,18 +411,21 @@ func readConnectorAws(d *schema.ResourceData, connector *nextgen.ConnectorInfo)
"access_key_ref": connector.Aws.Credential.ManualConfig.AccessKeyRef,
"secret_key_ref": connector.Aws.Credential.ManualConfig.SecretKeyRef,
"delegate_selectors": connector.Aws.DelegateSelectors,
"region": connector.Aws.Credential.Region,
},
})
case nextgen.AwsAuthTypes.Irsa:
d.Set("irsa", []map[string]interface{}{
{
"delegate_selectors": connector.Aws.DelegateSelectors,
"region": connector.Aws.Credential.Region,
},
})
case nextgen.AwsAuthTypes.InheritFromDelegate:
d.Set("inherit_from_delegate", []map[string]interface{}{
{
"delegate_selectors": connector.Aws.DelegateSelectors,
"region": connector.Aws.Credential.Region,
},
})
default:
Expand Down
15 changes: 15 additions & 0 deletions internal/service/platform/connector/aws_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ func DatasourceConnectorAws() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"region": {
Description: "Test Region to perform Connection test of AWS Connector" + secret_ref_text,
Type: schema.TypeString,
Optional: true,
},
},
},
},
Expand All @@ -53,6 +58,11 @@ func DatasourceConnectorAws() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"region": {
Description: "Test Region to perform Connection test of AWS Connector" + secret_ref_text,
Type: schema.TypeString,
Optional: true,
},
},
},
},
Expand All @@ -68,6 +78,11 @@ func DatasourceConnectorAws() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"region": {
Description: "Test Region to perform Connection test of AWS Connector" + secret_ref_text,
Type: schema.TypeString,
Optional: true,
},
},
},
},
Expand Down
8 changes: 8 additions & 0 deletions internal/service/platform/connector/aws_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestAccDataSourceConnectorAws(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "description", "test"),
resource.TestCheckResourceAttr(resourceName, "tags.#", "1"),
resource.TestCheckResourceAttr(resourceName, "inherit_from_delegate.0.delegate_selectors.#", "1"),
resource.TestCheckResourceAttr(resourceName, "inherit_from_delegate.0.region", "us-east-1"),
),
},
},
Expand Down Expand Up @@ -59,6 +60,7 @@ func TestAccDataSourceConnectorAwsFullJitterBackOff(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "full_jitter_backoff_strategy.0.base_delay", "10"),
resource.TestCheckResourceAttr(resourceName, "full_jitter_backoff_strategy.0.max_backoff_time", "65"),
resource.TestCheckResourceAttr(resourceName, "cross_account_access.0.role_arn", "test"),
resource.TestCheckResourceAttr(resourceName, "inherit_from_delegate.0.region", "us-east-1"),
),
},
},
Expand Down Expand Up @@ -88,6 +90,7 @@ func TestAccDataSourceConnectorAwsEqualJitterBackOff(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "equal_jitter_backoff_strategy.0.retry_count", "3"),
resource.TestCheckResourceAttr(resourceName, "equal_jitter_backoff_strategy.0.base_delay", "10"),
resource.TestCheckResourceAttr(resourceName, "equal_jitter_backoff_strategy.0.max_backoff_time", "65"),
resource.TestCheckResourceAttr(resourceName, "inherit_from_delegate.0.region", "us-east-1"),
),
},
},
Expand Down Expand Up @@ -116,6 +119,7 @@ func TestAccDataSourceConnectorAwsFixedDelayBackOff(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "inherit_from_delegate.0.delegate_selectors.#", "1"),
resource.TestCheckResourceAttr(resourceName, "fixed_delay_backoff_strategy.0.retry_count", "3"),
resource.TestCheckResourceAttr(resourceName, "fixed_delay_backoff_strategy.0.fixed_backoff", "10"),
resource.TestCheckResourceAttr(resourceName, "inherit_from_delegate.0.region", "us-east-1"),
),
},
},
Expand All @@ -132,6 +136,7 @@ func testAccDataSourceConnectorAws(name string) string {
inherit_from_delegate {
delegate_selectors = ["harness-delegate"]
region = "us-east-1"
}
}
Expand All @@ -151,6 +156,7 @@ func testAccDataSourceConnectorAwsEqualJitterBackOff(name string) string {
inherit_from_delegate {
delegate_selectors = ["harness-delegate"]
region = "us-east-1"
}
equal_jitter_backoff_strategy {
base_delay = 10
Expand All @@ -175,6 +181,7 @@ func testAccDataSourceConnectorAwsFullJitterBackOff(name string) string {
inherit_from_delegate {
delegate_selectors = ["harness-delegate"]
region = "us-east-1"
}
full_jitter_backoff_strategy {
base_delay = 10
Expand Down Expand Up @@ -202,6 +209,7 @@ func testAccDataSourceConnectorAwsFixedDelayBackOff(name string) string {
inherit_from_delegate {
delegate_selectors = ["harness-delegate"]
region = "us-east-1"
}
fixed_delay_backoff_strategy {
fixed_backoff = 10
Expand Down
Loading

0 comments on commit dfc8eb7

Please sign in to comment.