Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS updates #1124

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 41 additions & 17 deletions internal/service/cd_nextgen/connector/cloudProviders/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,23 @@ func ResourceConnectorAws() *schema.Resource {
Type: schema.TypeString,
Required: true,
},
"session_token_ref": {
Description: "Reference to the Harness secret containing the aws session token." + secret_ref_text,
Type: schema.TypeString,
Optional: true,
},
"session_token_ref": {
Description: "Reference to the Harness secret containing the aws session token." + secret_ref_text,
Type: schema.TypeString,
Optional: true,
},
"delegate_selectors": {
Description: "Connect only use delegates with these tags.",
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"execute_on_delegate": {
Description: "Execute on delegate or not.",
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"region": {
Description: "Test Region to perform Connection test of AWS Connector" + secret_ref_text,
Type: schema.TypeString,
Expand Down Expand Up @@ -170,6 +176,12 @@ func ResourceConnectorAws() *schema.Resource {
Required: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"execute_on_delegate": {
Description: "Execute on delegate or not.",
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"region": {
Description: "Test Region to perform Connection test of AWS Connector." + secret_ref_text,
Type: schema.TypeString,
Expand Down Expand Up @@ -351,14 +363,18 @@ func buildConnectorAws(d *schema.ResourceData) *nextgen.ConnectorInfo {
connector.Aws.Credential.ManualConfig.SecretKeyRef = attr
}

if attr := config["session_token_ref"].(string); attr != "" {
connector.Aws.Credential.ManualConfig.SessionTokenRef = attr
}
if attr := config["session_token_ref"].(string); attr != "" {
connector.Aws.Credential.ManualConfig.SessionTokenRef = attr
}

if attr := config["delegate_selectors"].(*schema.Set).List(); len(attr) > 0 {
connector.Aws.DelegateSelectors = utils.InterfaceSliceToStringSlice(attr)
}

if attr, ok := d.GetOk("execute_on_delegate"); ok {
connector.Aws.ExecuteOnDelegate = attr.(bool)
}

if attr := config["region"].(string); attr != "" {
connector.Aws.Credential.Region = attr
}
Expand Down Expand Up @@ -403,6 +419,10 @@ func buildConnectorAws(d *schema.ResourceData) *nextgen.ConnectorInfo {
connector.Aws.DelegateSelectors = utils.InterfaceSliceToStringSlice(attr)
}

if attr, ok := d.GetOk("execute_on_delegate"); ok {
connector.Aws.ExecuteOnDelegate = attr.(bool)
}

if attr := config["region"].(string); attr != "" {
connector.Aws.Credential.Region = attr
}
Expand Down Expand Up @@ -473,16 +493,19 @@ func buildConnectorAws(d *schema.ResourceData) *nextgen.ConnectorInfo {
}

func readConnectorAws(d *schema.ResourceData, connector *nextgen.ConnectorInfo) error {

d.Set("execute_on_delegate", connector.Aws.ExecuteOnDelegate)
switch connector.Aws.Credential.Type_ {
case nextgen.AwsAuthTypes.ManualConfig:
d.Set("manual", []map[string]interface{}{
{
"access_key": connector.Aws.Credential.ManualConfig.AccessKey,
"access_key_ref": connector.Aws.Credential.ManualConfig.AccessKeyRef,
"secret_key_ref": connector.Aws.Credential.ManualConfig.SecretKeyRef,
"session_token_ref": connector.Aws.Credential.ManualConfig.SessionTokenRef,
"delegate_selectors": connector.Aws.DelegateSelectors,
"region": connector.Aws.Credential.Region,
"access_key": connector.Aws.Credential.ManualConfig.AccessKey,
"access_key_ref": connector.Aws.Credential.ManualConfig.AccessKeyRef,
"secret_key_ref": connector.Aws.Credential.ManualConfig.SecretKeyRef,
"session_token_ref": connector.Aws.Credential.ManualConfig.SessionTokenRef,
"delegate_selectors": connector.Aws.DelegateSelectors,
"execute_on_delegate": connector.Aws.ExecuteOnDelegate,
"region": connector.Aws.Credential.Region,
},
})
case nextgen.AwsAuthTypes.Irsa:
Expand All @@ -502,9 +525,10 @@ func readConnectorAws(d *schema.ResourceData, connector *nextgen.ConnectorInfo)
case nextgen.AwsAuthTypes.OidcAuthentication:
d.Set("oidc_authentication", []map[string]interface{}{
{
"iam_role_arn": connector.Aws.Credential.OidcConfig.IamRoleArn,
"delegate_selectors": connector.Aws.DelegateSelectors,
"region": connector.Aws.Credential.Region,
"iam_role_arn": connector.Aws.Credential.OidcConfig.IamRoleArn,
"delegate_selectors": connector.Aws.DelegateSelectors,
"execute_on_delegate": connector.Aws.ExecuteOnDelegate,
"region": connector.Aws.Credential.Region,
},
})
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,22 @@ func DatasourceConnectorAws() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"session_token_ref": {
Description: "Reference to the Harness secret containing the aws session token." + secret_ref_text,
Type: schema.TypeString,
Optional: true,
},
"session_token_ref": {
Description: "Reference to the Harness secret containing the aws session token." + secret_ref_text,
Type: schema.TypeString,
Optional: true,
},
"delegate_selectors": {
Description: "Connect only use delegates with these tags.",
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"execute_on_delegate": {
Description: "Execute on delegate or not.",
Type: schema.TypeBool,
Computed: true,
},
"region": {
Description: "Test Region to perform Connection test of AWS Connector" + secret_ref_text,
Type: schema.TypeString,
Expand All @@ -68,6 +73,11 @@ func DatasourceConnectorAws() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"execute_on_delegate": {
Description: "Execute on delegate or not.",
Type: schema.TypeBool,
Computed: true,
},
"region": {
Description: "Test Region to perform Connection test of AWS Connector" + secret_ref_text,
Type: schema.TypeString,
Expand Down Expand Up @@ -113,6 +123,11 @@ func DatasourceConnectorAws() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"execute_on_delegate": {
Description: "Execute on delegate or not.",
Type: schema.TypeBool,
Computed: true,
},
"region": {
Description: "Test Region to perform Connection test of AWS Connector" + secret_ref_text,
Type: schema.TypeString,
Expand Down