Skip to content

Commit

Permalink
F/resource aws codestarconnections connection - support for host_arn (#…
Browse files Browse the repository at this point in the history
…19284)

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* f/aws_securityhub_member: email is optional variable

* support for GitHubEnterpriseServer host_arn on codestarconnections_connection

* support for GitHubEnterpriseServer host_arn on codestarconnections_connection

* Add CHANGELOG entry.

* d/aws_codestarconnections_connection: Add 'host_arn' attribute.

Co-authored-by: Kit Ewbank <Kit_Ewbank@hotmail.com>
  • Loading branch information
nikhil-goenka and ewbankkit authored May 10, 2021
1 parent c777989 commit 50521dd
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .changelog/19284.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/aws_codestarconnections_connection: Add `host_arn` argument
```

```release-note:enhancement
data-source/aws_codestarconnections_connection: Add `host_arn` attribute
```
6 changes: 6 additions & 0 deletions aws/data_source_aws_codestarconnections_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ func dataSourceAwsCodeStarConnectionsConnection() *schema.Resource {
Computed: true,
},

"host_arn": {
Type: schema.TypeString,
Computed: true,
},

"name": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -54,6 +59,7 @@ func dataSourceAwsCodeStarConnectionsConnectionRead(d *schema.ResourceData, meta

d.SetId(arn)
d.Set("connection_status", connection.ConnectionStatus)
d.Set("host_arn", connection.HostArn)
d.Set("name", connection.ConnectionName)
d.Set("provider_type", connection.ProviderType)

Expand Down
28 changes: 23 additions & 5 deletions aws/resource_aws_codestarconnections_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,21 @@ func resourceAwsCodeStarConnectionsConnection() *schema.Resource {
ForceNew: true,
},

"host_arn": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ConflictsWith: []string{"provider_type"},
ValidateFunc: validateArn,
},

"provider_type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice(codestarconnections.ProviderType_Values(), false),
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Computed: true,
ConflictsWith: []string{"host_arn"},
ValidateFunc: validation.StringInSlice(codestarconnections.ProviderType_Values(), false),
},

"tags": tagsSchema(),
Expand All @@ -62,7 +72,14 @@ func resourceAwsCodeStarConnectionsConnectionCreate(d *schema.ResourceData, meta

params := &codestarconnections.CreateConnectionInput{
ConnectionName: aws.String(d.Get("name").(string)),
ProviderType: aws.String(d.Get("provider_type").(string)),
}

if v, ok := d.GetOk("provider_type"); ok {
params.ProviderType = aws.String(v.(string))
}

if v, ok := d.GetOk("host_arn"); ok {
params.HostArn = aws.String(v.(string))
}

if len(tags) > 0 {
Expand Down Expand Up @@ -103,6 +120,7 @@ func resourceAwsCodeStarConnectionsConnectionRead(d *schema.ResourceData, meta i
d.Set("arn", connection.ConnectionArn)
d.Set("connection_status", connection.ConnectionStatus)
d.Set("name", connection.ConnectionName)
d.Set("host_arn", connection.HostArn)
d.Set("provider_type", connection.ProviderType)

tags, err := keyvaluetags.CodestarconnectionsListTags(conn, arn)
Expand Down
47 changes: 47 additions & 0 deletions aws/resource_aws_codestarconnections_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,38 @@ func TestAccAWSCodeStarConnectionsConnection_Basic(t *testing.T) {
})
}

func TestAccAWSCodeStarConnectionsConnection_HostArn(t *testing.T) {
var v codestarconnections.Connection
resourceName := "aws_codestarconnections_connection.test"
rName := acctest.RandomWithPrefix("tf-acc-test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(codestarconnections.EndpointsID, t) },
ErrorCheck: testAccErrorCheck(t, codestarconnections.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCodeStarConnectionsConnectionDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSCodeStarConnectionsConnectionConfigHostArn(rName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSCodeStarConnectionsConnectionExists(resourceName, &v),
testAccMatchResourceAttrRegionalARN(resourceName, "id", "codestar-connections", regexp.MustCompile("connection/.+")),
testAccMatchResourceAttrRegionalARN(resourceName, "arn", "codestar-connections", regexp.MustCompile("connection/.+")),
testAccMatchResourceAttrRegionalARN(resourceName, "host_arn", "codestar-connections", regexp.MustCompile("host/.+")),
resource.TestCheckResourceAttr(resourceName, "provider_type", codestarconnections.ProviderTypeGitHubEnterpriseServer),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "connection_status", codestarconnections.ConnectionStatusPending),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSCodeStarConnectionsConnection_disappears(t *testing.T) {
var v codestarconnections.Connection
resourceName := "aws_codestarconnections_connection.test"
Expand Down Expand Up @@ -166,6 +198,21 @@ resource "aws_codestarconnections_connection" "test" {
`, rName)
}

func testAccAWSCodeStarConnectionsConnectionConfigHostArn(rName string) string {
return fmt.Sprintf(`
resource "aws_codestarconnections_host" "test" {
name = %[1]q
provider_endpoint = "https://test.com"
provider_type = "GitHubEnterpriseServer"
}
resource "aws_codestarconnections_connection" "test" {
name = %[1]q
host_arn = aws_codestarconnections_host.test.arn
}
`, rName)
}

func testAccAWSCodeStarConnectionsConnectionConfigTags1(rName string, tagKey1 string, tagValue1 string) string {
return fmt.Sprintf(`
resource "aws_codestarconnections_connection" "test" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ In addition to all arguments above, the following attributes are exported:

* `connection_status` - The CodeStar Connection status. Possible values are `PENDING`, `AVAILABLE` and `ERROR`.
* `id` - The CodeStar Connection ARN.
* `host_arn` - The Amazon Resource Name (ARN) of the host associated with the connection.
* `name` - The name of the CodeStar Connection. The name is unique in the calling AWS account.
* `provider_type` - The name of the external provider where your third-party code repository is configured. Possible values are `Bitbucket`, `GitHub`, or `GitHubEnterpriseServer`.
* `tags` - Map of key-value resource tags to associate with the resource.
3 changes: 2 additions & 1 deletion website/docs/r/codestarconnections_connection.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ resource "aws_codepipeline" "example" {
The following arguments are supported:

* `name` - (Required) The name of the connection to be created. The name must be unique in the calling AWS account. Changing `name` will create a new resource.
* `provider_type` - (Required) The name of the external provider where your third-party code repository is configured. Valid values are `Bitbucket`, `GitHub`, or `GitHubEnterpriseServer`. Changing `provider_type` will create a new resource.
* `provider_type` - (Optional) The name of the external provider where your third-party code repository is configured. Valid values are `Bitbucket`, `GitHub` or `GitHubEnterpriseServer`. Changing `provider_type` will create a new resource. Conflicts with `host_arn`
* `host_arn` - (Optional) The Amazon Resource Name (ARN) of the host associated with the connection. Conflicts with `provider_type`
* `tags` - (Optional) Map of key-value resource tags to associate with the resource. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.

## Attributes Reference
Expand Down

0 comments on commit 50521dd

Please sign in to comment.