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

Support MongoDB connection type for AWS Glue #13011

Merged
merged 3 commits into from
Apr 30, 2020
Merged
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
1 change: 1 addition & 0 deletions aws/resource_aws_glue_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func resourceAwsGlueConnection() *schema.Resource {
ValidateFunc: validation.StringInSlice([]string{
glue.ConnectionTypeJdbc,
glue.ConnectionTypeSftp,
glue.ConnectionTypeMongodb,
}, false),
},
"description": {
Expand Down
49 changes: 49 additions & 0 deletions aws/resource_aws_glue_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,39 @@ func TestAccAWSGlueConnection_Basic(t *testing.T) {
})
}

func TestAccAWSGlueConnection_MongoDB(t *testing.T) {
var connection glue.Connection

rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(5))
resourceName := "aws_glue_connection.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSGlueConnectionDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSGlueConnectionConfig_MongoDB(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSGlueConnectionExists(resourceName, &connection),
resource.TestCheckResourceAttr(resourceName, "connection_properties.%", "3"),
resource.TestCheckResourceAttr(resourceName, "connection_properties.CONNECTION_URL", "mongodb://testdb.com:27017/databasename"),
resource.TestCheckResourceAttr(resourceName, "connection_properties.USERNAME", "testusername"),
resource.TestCheckResourceAttr(resourceName, "connection_properties.PASSWORD", "testpassword"),
resource.TestCheckResourceAttr(resourceName, "connection_type", "MONGODB"),
resource.TestCheckResourceAttr(resourceName, "match_criteria.#", "0"),
resource.TestCheckResourceAttr(resourceName, "physical_connection_requirements.#", "0"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSGlueConnection_Description(t *testing.T) {
var connection glue.Connection

Expand Down Expand Up @@ -439,3 +472,19 @@ resource "aws_glue_connection" "test" {
}
`, rName)
}

func testAccAWSGlueConnectionConfig_MongoDB(rName string) string {
return fmt.Sprintf(`
resource "aws_glue_connection" "test" {
drexler marked this conversation as resolved.
Show resolved Hide resolved
connection_properties = {
CONNECTION_URL = "mongodb://testdb.com:27017/databasename"
PASSWORD = "testpassword"
USERNAME = "testusername"
}

connection_type = "MONGODB"

name = "%s"
}
`, rName)
}
2 changes: 1 addition & 1 deletion website/docs/r/glue_connection.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The following arguments are supported:

* `catalog_id` – (Optional) The ID of the Data Catalog in which to create the connection. If none is supplied, the AWS account ID is used by default.
* `connection_properties` – (Required) A map of key-value pairs used as parameters for this connection.
* `connection_type` – (Optional) The type of the connection. Defaults to `JBDC`.
* `connection_type` – (Optional) The type of the connection. Supported are: `JDBC`, `MONGODB`. Defaults to `JBDC`.
* `description` – (Optional) Description of the connection.
* `match_criteria` – (Optional) A list of criteria that can be used in selecting this connection.
* `name` – (Required) The name of the connection.
Expand Down