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

New resource - Glue crawlers #4484

Closed
wants to merge 60 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
76aee79
WIP - Add AWS Glue Crawler
darrenhaken Jan 18, 2018
c3cbbe7
Merge branch 'master' of github.com:terraform-providers/terraform-pro…
darrenhaken Mar 13, 2018
b0ba213
WIP - Finally got a failing test with the bare min of crawler
darrenhaken Mar 13, 2018
1b0babf
WIP with failing test
darrenhaken Mar 15, 2018
8eb8421
Merge remote-tracking branch 'upstream/master' into glue_crawlers
darrenhaken Apr 28, 2018
f579f8d
Switch service role for Glue
darrenhaken Apr 28, 2018
f43a0a2
make glue crawler creation wait for role ready
f0rk May 30, 2018
9396692
Merge pull request #1 from f0rk/glue_crawlers_fork
darrenhaken May 31, 2018
9ca8a90
Add description and schedule to glue crawlers
darrenhaken May 31, 2018
71db475
Merge remote-tracking branch 'upstream/master' into glue_crawlers
darrenhaken Jun 1, 2018
6801b72
Add classifiers to glue crawlers
darrenhaken Jun 1, 2018
97496eb
Add glue crawler table prefix
darrenhaken Jun 1, 2018
d41e67f
Merge remote-tracking branch 'upstream/master' into glue_crawlers
darrenhaken Jun 12, 2018
b5fbdf4
Change role names to not use the default.
darrenhaken Jun 12, 2018
cf9b1e2
Change classifier name
darrenhaken Jun 12, 2018
8f1f921
Add schema change policy
darrenhaken Jun 13, 2018
8287580
Add creating glue db as part of tests.
darrenhaken Jun 14, 2018
a78ca5d
Add glue crawler s3 targets
darrenhaken Jun 15, 2018
15569a0
Add s3 target exclusions to glue crawler
darrenhaken Jun 16, 2018
030df68
Fix assertion for glue crawler basic test
darrenhaken Jun 16, 2018
8e02838
WIP for glue JDBC crawlers
darrenhaken Jun 17, 2018
dac4615
Remove experiment on Glue JDBC crawler
darrenhaken Jun 17, 2018
0f087a3
Attempt to add full glue access but test still fails
darrenhaken Jun 17, 2018
2d2b9c3
Change name on Glue JDBC crawler
darrenhaken Jun 18, 2018
9d9d676
Add classifiers to glue crawlers
darrenhaken Jun 18, 2018
43ed483
Add glue crawler configuration
darrenhaken Jun 18, 2018
35e1ee4
Merge remote-tracking branch 'upstream/master' into glue_crawlers
darrenhaken Jun 18, 2018
7e625f9
resource/aws_kinesis_firehose_delivery_stream: Support data_format_co…
bflad Jun 5, 2018
5c397f1
resource/aws_kinesis_firehose_delivery_stream: Fix imports formatting…
bflad Jun 15, 2018
fcd0f8b
resource/aws_kinesis_firehose_delivery_stream: Remove else statements…
bflad Jun 15, 2018
b497605
resource/aws_kinesis_firehose_delivery_stream: Implement ConflictsWit…
bflad Jun 15, 2018
5da31f8
add new resource aws_neptune_cluster_parameter_group
saravanan30erd Jun 16, 2018
689b0bb
add acceptance test
saravanan30erd Jun 16, 2018
0659c60
add document for neptune_cluster_parameter_group
saravanan30erd Jun 16, 2018
03a7c40
fix the issue in setting tags
saravanan30erd Jun 17, 2018
a2ec019
resource/aws_cognito_user_pool_client: Prevent panic with updating re…
bflad Jun 18, 2018
7e2307c
tests/resource/aws_kinesis_firehose_delivery_stream: Verify updates t…
bflad Jun 18, 2018
3c9c2fa
resource/aws_kinesis_firehose_delivery_stream: Mark data_format_conve…
bflad Jun 18, 2018
26fb58c
Update CHANGELOG for #4842
bflad Jun 18, 2018
357bb86
fix the unit testing
saravanan30erd Jun 18, 2018
c8d17fe
corrections based on feedback
saravanan30erd Jun 18, 2018
a2fb36f
Update CHANGELOG for #4868
bflad Jun 18, 2018
59a9dc4
tests/resource/aws_neptune_cluster_parameter_group: Enhance acceptanc…
bflad Jun 18, 2018
53709e3
Update CHANGELOG for #4860
bflad Jun 18, 2018
e016ace
resource/aws_neptune_parameter_group: Support tags argument and arn a…
bflad Jun 18, 2018
037be34
Add enabled_cloudwatch_logs_exports to rds cluster resource
Jun 18, 2018
e34e4ac
New Data Source: aws_vpc_dhcp_options
bflad Jun 18, 2018
e39ad32
data-source/aws_vpc_dhcp_options: Support filter argument
bflad Jun 19, 2018
cfa0c87
data-source/aws_vpc_dhcp_options: Fix imports formatting
bflad Jun 19, 2018
2f3d7eb
data-source/aws_vpc_dhcp_options: Remove ValidateFunc from dhcp_optio…
bflad Jun 19, 2018
35f1f9d
tests/data-source/aws_vpc_dhcp_options: Check no matching, multiple m…
bflad Jun 19, 2018
c7f2925
tests/resource/aws_neptune_parameter_group: Use %q instead of "%s" in…
bflad Jun 19, 2018
a8e0dc2
Update CHANGELOG for #4873
bflad Jun 19, 2018
3be906a
Update CHANGELOG for #4878
bflad Jun 19, 2018
aff7114
[squash] review remarks
Jun 19, 2018
e146939
Update CHANGELOG for #4875
bflad Jun 19, 2018
51a1ae0
Rename glue crawler resource
darrenhaken Jun 20, 2018
e5832d7
Made some of the glue crawler changes based on PR feedback
darrenhaken Jun 20, 2018
1f05ca1
Add random names to glue crawler tests
darrenhaken Jun 20, 2018
ac4b520
Revert a change for glue crawler schema change
darrenhaken Jun 20, 2018
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
FEATURES:

* **New Data Source:** `aws_cloudformation_export` [GH-2180]
* **New Data Source:** `aws_vpc_dhcp_options` [GH-4878]
* **New Resource:** `aws_neptune_cluster_parameter_group` [GH-4860]
* **New Resource:** `aws_neptune_subnet_group` [GH-4782]

ENHANCEMENTS:

* resource/aws_codedeploy_app: Add `compute_platform` argument [GH-4811]
* resource/aws_kinesis_firehose_delivery_stream: Support extended S3 destination `data_format_conversion_configuration` [GH-4842]
* resource/aws_neptune_parameter_group: Add `tags` argument and `arn` attribute [GH-4873]
* resource/aws_rds_cluster: Add `enabled_cloudwatch_logs_exports` argument [GH-4875]

BUG FIXES:

* resource/aws_batch_job_definition: Force resource recreation on retry_strategy attempts updates [GH-4854]
* resource/aws_cognito_user_pool_client: Prevent panic with updating `refresh_token_validity` [GH-4868]

## 1.23.0 (June 14, 2018)

Expand Down
126 changes: 126 additions & 0 deletions aws/data_source_aws_vpc_dhcp_options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package aws

import (
"errors"
"fmt"
"log"
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform/helper/schema"
)

func dataSourceAwsVpcDhcpOptions() *schema.Resource {
return &schema.Resource{
Read: dataSourceAwsVpcDhcpOptionsRead,

Schema: map[string]*schema.Schema{
"dhcp_options_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"domain_name": {
Type: schema.TypeString,
Computed: true,
},
"domain_name_servers": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"filter": ec2CustomFiltersSchema(),
"netbios_name_servers": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"netbios_node_type": {
Type: schema.TypeString,
Computed: true,
},
"ntp_servers": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"tags": tagsSchemaComputed(),
},
}
}

func dataSourceAwsVpcDhcpOptionsRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn

input := &ec2.DescribeDhcpOptionsInput{}

if v, ok := d.GetOk("dhcp_options_id"); ok && v.(string) != "" {
input.DhcpOptionsIds = []*string{aws.String(v.(string))}
}

input.Filters = append(input.Filters, buildEC2CustomFilterList(
d.Get("filter").(*schema.Set),
)...)
if len(input.Filters) == 0 {
// Don't send an empty filters list; the EC2 API won't accept it.
input.Filters = nil
}

log.Printf("[DEBUG] Reading EC2 DHCP Options: %s", input)
output, err := conn.DescribeDhcpOptions(input)
if err != nil {
if isNoSuchDhcpOptionIDErr(err) {
return errors.New("No matching EC2 DHCP Options found")
}
return fmt.Errorf("error reading EC2 DHCP Options: %s", err)
}

if len(output.DhcpOptions) == 0 {
return errors.New("No matching EC2 DHCP Options found")
}

if len(output.DhcpOptions) > 1 {
return errors.New("Multiple matching EC2 DHCP Options found")
}

dhcpOptionID := aws.StringValue(output.DhcpOptions[0].DhcpOptionsId)
d.SetId(dhcpOptionID)
d.Set("dhcp_options_id", dhcpOptionID)

dhcpConfigurations := output.DhcpOptions[0].DhcpConfigurations

for _, dhcpConfiguration := range dhcpConfigurations {
key := aws.StringValue(dhcpConfiguration.Key)
tfKey := strings.Replace(key, "-", "_", -1)

if len(dhcpConfiguration.Values) == 0 {
continue
}

switch key {
case "domain-name":
d.Set(tfKey, aws.StringValue(dhcpConfiguration.Values[0].Value))
case "domain-name-servers":
if err := d.Set(tfKey, flattenEc2AttributeValues(dhcpConfiguration.Values)); err != nil {
return fmt.Errorf("error setting %s: %s", tfKey, err)
}
case "netbios-name-servers":
if err := d.Set(tfKey, flattenEc2AttributeValues(dhcpConfiguration.Values)); err != nil {
return fmt.Errorf("error setting %s: %s", tfKey, err)
}
case "netbios-node-type":
d.Set(tfKey, aws.StringValue(dhcpConfiguration.Values[0].Value))
case "ntp-servers":
if err := d.Set(tfKey, flattenEc2AttributeValues(dhcpConfiguration.Values)); err != nil {
return fmt.Errorf("error setting %s: %s", tfKey, err)
}
}
}

if err := d.Set("tags", d.Set("tags", tagsToMap(output.DhcpOptions[0].Tags))); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}

return nil
}
139 changes: 139 additions & 0 deletions aws/data_source_aws_vpc_dhcp_options_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package aws

import (
"fmt"
"regexp"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccDataSourceAwsVpcDhcpOptions_basic(t *testing.T) {
resourceName := "aws_vpc_dhcp_options.test"
datasourceName := "data.aws_vpc_dhcp_options.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceAwsVpcDhcpOptionsConfig_Missing,
ExpectError: regexp.MustCompile(`No matching EC2 DHCP Options found`),
},
{
Config: testAccDataSourceAwsVpcDhcpOptionsConfig_DhcpOptionsID,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(datasourceName, "dhcp_options_id", resourceName, "id"),
resource.TestCheckResourceAttrPair(datasourceName, "domain_name", resourceName, "domain_name"),
resource.TestCheckResourceAttrPair(datasourceName, "domain_name_servers.#", resourceName, "domain_name_servers.#"),
resource.TestCheckResourceAttrPair(datasourceName, "domain_name_servers.0", resourceName, "domain_name_servers.0"),
resource.TestCheckResourceAttrPair(datasourceName, "domain_name_servers.1", resourceName, "domain_name_servers.1"),
resource.TestCheckResourceAttrPair(datasourceName, "netbios_name_servers.#", resourceName, "netbios_name_servers.#"),
resource.TestCheckResourceAttrPair(datasourceName, "netbios_name_servers.0", resourceName, "netbios_name_servers.0"),
resource.TestCheckResourceAttrPair(datasourceName, "netbios_node_type", resourceName, "netbios_node_type"),
resource.TestCheckResourceAttrPair(datasourceName, "ntp_servers.#", resourceName, "ntp_servers.#"),
resource.TestCheckResourceAttrPair(datasourceName, "ntp_servers.0", resourceName, "ntp_servers.0"),
resource.TestCheckResourceAttrPair(datasourceName, "tags.%", resourceName, "tags.%"),
resource.TestCheckResourceAttrPair(datasourceName, "tags.Name", resourceName, "tags.Name"),
),
},
},
})
}

func TestAccDataSourceAwsVpcDhcpOptions_Filter(t *testing.T) {
rInt := acctest.RandInt()
resourceName := "aws_vpc_dhcp_options.test"
datasourceName := "data.aws_vpc_dhcp_options.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceAwsVpcDhcpOptionsConfig_Filter(rInt, 1),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(datasourceName, "dhcp_options_id", resourceName, "id"),
resource.TestCheckResourceAttrPair(datasourceName, "domain_name", resourceName, "domain_name"),
resource.TestCheckResourceAttrPair(datasourceName, "domain_name_servers.#", resourceName, "domain_name_servers.#"),
resource.TestCheckResourceAttrPair(datasourceName, "domain_name_servers.0", resourceName, "domain_name_servers.0"),
resource.TestCheckResourceAttrPair(datasourceName, "domain_name_servers.1", resourceName, "domain_name_servers.1"),
resource.TestCheckResourceAttrPair(datasourceName, "netbios_name_servers.#", resourceName, "netbios_name_servers.#"),
resource.TestCheckResourceAttrPair(datasourceName, "netbios_name_servers.0", resourceName, "netbios_name_servers.0"),
resource.TestCheckResourceAttrPair(datasourceName, "netbios_node_type", resourceName, "netbios_node_type"),
resource.TestCheckResourceAttrPair(datasourceName, "ntp_servers.#", resourceName, "ntp_servers.#"),
resource.TestCheckResourceAttrPair(datasourceName, "ntp_servers.0", resourceName, "ntp_servers.0"),
resource.TestCheckResourceAttrPair(datasourceName, "tags.%", resourceName, "tags.%"),
resource.TestCheckResourceAttrPair(datasourceName, "tags.Name", resourceName, "tags.Name"),
),
},
{
Config: testAccDataSourceAwsVpcDhcpOptionsConfig_Filter(rInt, 2),
ExpectError: regexp.MustCompile(`Multiple matching EC2 DHCP Options found`),
},
},
})
}

const testAccDataSourceAwsVpcDhcpOptionsConfig_Missing = `
data "aws_vpc_dhcp_options" "test" {
dhcp_options_id = "does-not-exist"
}
`

const testAccDataSourceAwsVpcDhcpOptionsConfig_DhcpOptionsID = `
resource "aws_vpc_dhcp_options" "incorrect" {
domain_name = "tf-acc-test-incorrect.example.com"
}

resource "aws_vpc_dhcp_options" "test" {
domain_name = "service.consul"
domain_name_servers = ["127.0.0.1", "10.0.0.2"]
netbios_name_servers = ["127.0.0.1"]
netbios_node_type = 2
ntp_servers = ["127.0.0.1"]

tags {
Name = "tf-acc-test"
}
}

data "aws_vpc_dhcp_options" "test" {
dhcp_options_id = "${aws_vpc_dhcp_options.test.id}"
}
`

func testAccDataSourceAwsVpcDhcpOptionsConfig_Filter(rInt, count int) string {
return fmt.Sprintf(`
resource "aws_vpc_dhcp_options" "incorrect" {
domain_name = "tf-acc-test-incorrect.example.com"
}

resource "aws_vpc_dhcp_options" "test" {
count = %d

domain_name = "tf-acc-test-%d.example.com"
domain_name_servers = ["127.0.0.1", "10.0.0.2"]
netbios_name_servers = ["127.0.0.1"]
netbios_node_type = 2
ntp_servers = ["127.0.0.1"]

tags {
Name = "tf-acc-test-%d"
}
}

data "aws_vpc_dhcp_options" "test" {
filter {
name = "key"
values = ["domain-name"]
}

filter {
name = "value"
values = ["${aws_vpc_dhcp_options.test.0.domain_name}"]
}
}
`, count, rInt, rInt)
}
3 changes: 3 additions & 0 deletions aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ func Provider() terraform.ResourceProvider {
"aws_vpcs": dataSourceAwsVpcs(),
"aws_security_group": dataSourceAwsSecurityGroup(),
"aws_vpc": dataSourceAwsVpc(),
"aws_vpc_dhcp_options": dataSourceAwsVpcDhcpOptions(),
"aws_vpc_endpoint": dataSourceAwsVpcEndpoint(),
"aws_vpc_endpoint_service": dataSourceAwsVpcEndpointService(),
"aws_vpc_peering_connection": dataSourceAwsVpcPeeringConnection(),
Expand Down Expand Up @@ -412,6 +413,7 @@ func Provider() terraform.ResourceProvider {
"aws_glue_catalog_table": resourceAwsGlueCatalogTable(),
"aws_glue_classifier": resourceAwsGlueClassifier(),
"aws_glue_connection": resourceAwsGlueConnection(),
"aws_glue_crawler": resourceAwsGlueCrawler(),
"aws_glue_job": resourceAwsGlueJob(),
"aws_glue_trigger": resourceAwsGlueTrigger(),
"aws_guardduty_detector": resourceAwsGuardDutyDetector(),
Expand Down Expand Up @@ -625,6 +627,7 @@ func Provider() terraform.ResourceProvider {
"aws_batch_job_definition": resourceAwsBatchJobDefinition(),
"aws_batch_job_queue": resourceAwsBatchJobQueue(),
"aws_neptune_subnet_group": resourceAwsNeptuneSubnetGroup(),
"aws_neptune_cluster_parameter_group": resourceAwsNeptuneClusterParameterGroup(),

// ALBs are actually LBs because they can be type `network` or `application`
// To avoid regressions, we will add a new resource for each and they both point
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_cognito_user_pool_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func resourceAwsCognitoUserPoolClientUpdate(d *schema.ResourceData, meta interfa
}

if d.HasChange("refresh_token_validity") {
params.RefreshTokenValidity = aws.Int64(d.Get("refresh_token_validity").(int64))
params.RefreshTokenValidity = aws.Int64(int64(d.Get("refresh_token_validity").(int)))
}

if d.HasChange("allowed_oauth_flows") {
Expand Down
40 changes: 40 additions & 0 deletions aws/resource_aws_cognito_user_pool_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,32 @@ func TestAccAWSCognitoUserPoolClient_importBasic(t *testing.T) {
})
}

func TestAccAWSCognitoUserPoolClient_RefreshTokenValidity(t *testing.T) {
rName := acctest.RandomWithPrefix("tf-acc-test")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSCognitoUserPoolClientDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSCognitoUserPoolClientConfig_RefreshTokenValidity(rName, 60),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSCognitoUserPoolClientExists("aws_cognito_user_pool_client.client"),
resource.TestCheckResourceAttr("aws_cognito_user_pool_client.client", "refresh_token_validity", "60"),
),
},
{
Config: testAccAWSCognitoUserPoolClientConfig_RefreshTokenValidity(rName, 120),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAWSCognitoUserPoolClientExists("aws_cognito_user_pool_client.client"),
resource.TestCheckResourceAttr("aws_cognito_user_pool_client.client", "refresh_token_validity", "120"),
),
},
},
})
}

func TestAccAWSCognitoUserPoolClient_allFields(t *testing.T) {
userPoolName := fmt.Sprintf("tf-acc-cognito-user-pool-%s", acctest.RandString(7))
clientName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
Expand Down Expand Up @@ -202,6 +228,20 @@ resource "aws_cognito_user_pool_client" "client" {
`, userPoolName, clientName)
}

func testAccAWSCognitoUserPoolClientConfig_RefreshTokenValidity(rName string, refreshTokenValidity int) string {
return fmt.Sprintf(`
resource "aws_cognito_user_pool" "pool" {
name = "%s"
}

resource "aws_cognito_user_pool_client" "client" {
name = "%s"
refresh_token_validity = %d
user_pool_id = "${aws_cognito_user_pool.pool.id}"
}
`, rName, rName, refreshTokenValidity)
}

func testAccAWSCognitoUserPoolClientConfig_allFields(userPoolName, clientName string) string {
return fmt.Sprintf(`
resource "aws_cognito_user_pool" "pool" {
Expand Down
Loading