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

add glue execution class option #26188

Merged
merged 14 commits into from
Aug 10, 2022
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
3 changes: 3 additions & 0 deletions .changelog/26188.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_glue_job: Add `execution_class` argument
```
102 changes: 53 additions & 49 deletions internal/service/glue/dev_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,15 +561,15 @@ func TestAccGlueDevEndpoint_disappears(t *testing.T) {
})
}

func testAccCheckDevEndpointExists(resourceName string, v *glue.DevEndpoint) resource.TestCheckFunc {
func testAccCheckDevEndpointExists(n string, v *glue.DevEndpoint) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[resourceName]
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("not found: %s", resourceName)
return fmt.Errorf("Not found: %s", n)
}

if rs.Primary.ID == "" {
return fmt.Errorf("no Glue Dev Endpoint ID is set")
return fmt.Errorf("No Glue Dev Endpoint ID is set")
}

conn := acctest.Provider.Meta().(*conns.AWSClient).GlueConn
Expand Down Expand Up @@ -638,28 +638,28 @@ data "aws_partition" "current" {}
}

func testAccDevEndpointConfig_basic(rName string) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %q
name = %[1]q
role_arn = aws_iam_role.test.arn
}
`, rName)
`, rName))
}

func testAccDevEndpointConfig_arguments(rName, argKey, argValue string) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %[1]q
role_arn = aws_iam_role.test.arn
arguments = {
%[2]q = %[3]q
}
}
`, rName, argKey, argValue)
`, rName, argKey, argValue))
}

func testAccDevEndpointConfig_arguments2(rName, argKey1, argValue1, argKey2, argValue2 string) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %[1]q
role_arn = aws_iam_role.test.arn
Expand All @@ -668,102 +668,102 @@ resource "aws_glue_dev_endpoint" "test" {
%[4]q = %[5]q
}
}
`, rName, argKey1, argValue1, argKey2, argValue2)
`, rName, argKey1, argValue1, argKey2, argValue2))
}

func testAccDevEndpointConfig_extraJarsS3Path(rName string, extraJarsS3Path string) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %q
name = %[1]q
role_arn = aws_iam_role.test.arn
extra_jars_s3_path = %q
extra_jars_s3_path = %[2]q
}
`, rName, extraJarsS3Path)
`, rName, extraJarsS3Path))
}

func testAccDevEndpointConfig_extraPythonLibsS3Path(rName string, extraPythonLibsS3Path string) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %q
name = %[1]q
role_arn = aws_iam_role.test.arn
extra_python_libs_s3_path = %q
extra_python_libs_s3_path = %[2]q
}
`, rName, extraPythonLibsS3Path)
`, rName, extraPythonLibsS3Path))
}

func testAccDevEndpointConfig_version(rName string, glueVersion string) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %[1]q
role_arn = aws_iam_role.test.arn
glue_version = %[2]q
}
`, rName, glueVersion)
`, rName, glueVersion))
}

func testAccDevEndpointConfig_numberOfNodes(rName string, numberOfNodes int) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %q
name = %[1]q
role_arn = aws_iam_role.test.arn
number_of_nodes = %d
number_of_nodes = %[2]d
}
`, rName, numberOfNodes)
`, rName, numberOfNodes))
}

func testAccDevEndpointConfig_numberOfWorkers(rName string, numberOfWorkers int) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %q
name = %[1]q
role_arn = aws_iam_role.test.arn
worker_type = "G.1X"
number_of_workers = %d
number_of_workers = %[2]d
}
`, rName, numberOfWorkers)
`, rName, numberOfWorkers))
}

func testAccDevEndpointConfig_publicKey(rName string, publicKey string) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %q
name = %[1]q
role_arn = aws_iam_role.test.arn
public_key = "%s"
public_key = %[2]q
}
`, rName, publicKey)
`, rName, publicKey))
}

func testAccDevEndpointConfig_publicKeys2(rName string, publicKey1 string, publicKey2 string) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %[1]q
role_arn = aws_iam_role.test.arn
public_keys = [%[2]q, %[3]q]
}
`, rName, publicKey1, publicKey2)
`, rName, publicKey1, publicKey2))
}

func testAccDevEndpointConfig_publicKeys3(rName string, publicKey1 string, publicKey2 string, publicKey3 string) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %[1]q
role_arn = aws_iam_role.test.arn
public_keys = [%[2]q, %[3]q, %[4]q]
}
`, rName, publicKey1, publicKey2, publicKey3)
`, rName, publicKey1, publicKey2, publicKey3))
}

func testAccDevEndpointConfig_publicKeys4(rName string, publicKey1 string, publicKey2 string, publicKey3 string, publicKey4 string) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %[1]q
role_arn = aws_iam_role.test.arn
public_keys = [%[2]q, %[3]q, %[4]q, %[5]q]
}
`, rName, publicKey1, publicKey2, publicKey3, publicKey4)
`, rName, publicKey1, publicKey2, publicKey3, publicKey4))
}

func testAccDevEndpointConfig_securityConfiguration(rName string) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %[1]q
role_arn = aws_iam_role.test.arn
Expand All @@ -787,7 +787,7 @@ resource "aws_glue_security_configuration" "test" {
}
}
}
`, rName)
`, rName))
}

func testAccDevEndpointConfig_subnetIDSecurityGroupIDs(rName string) string {
Expand Down Expand Up @@ -843,6 +843,10 @@ resource "aws_security_group" "test" {
name = %[1]q
vpc_id = aws_vpc.test.id

tags = {
Name = %[1]q
}

ingress {
from_port = 0
to_port = 0
Expand All @@ -866,7 +870,7 @@ resource "aws_security_group" "test" {
}

func testAccDevEndpointConfig_tags1(rName, tagKey1, tagValue1 string) string {
return testAccJobConfig_Base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %[1]q
role_arn = aws_iam_role.test.arn
Expand All @@ -875,11 +879,11 @@ resource "aws_glue_dev_endpoint" "test" {
%[2]q = %[3]q
}
}
`, rName, tagKey1, tagValue1)
`, rName, tagKey1, tagValue1))
}

func testAccDevEndpointConfig_tags2(rName, tagKey1, tagValue1, tagKey2, tagValue2 string) string {
return testAccJobConfig_Base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %[1]q
role_arn = aws_iam_role.test.arn
Expand All @@ -889,27 +893,27 @@ resource "aws_glue_dev_endpoint" "test" {
%[4]q = %[5]q
}
}
`, rName, tagKey1, tagValue1, tagKey2, tagValue2)
`, rName, tagKey1, tagValue1, tagKey2, tagValue2))
}

func testAccDevEndpointConfig_workerType(rName, workerType string) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %[1]q
role_arn = aws_iam_role.test.arn
worker_type = %[2]q
number_of_workers = 2
}
`, rName, workerType)
`, rName, workerType))
}

func testAccDevEndpointConfig_workerTypeStandard(rName string) string {
return testAccDevEndpointConfig_base(rName) + fmt.Sprintf(`
return acctest.ConfigCompose(testAccDevEndpointConfig_base(rName), fmt.Sprintf(`
resource "aws_glue_dev_endpoint" "test" {
name = %[1]q
role_arn = aws_iam_role.test.arn
worker_type = "Standard"
number_of_workers = 2
}
`, rName)
`, rName))
}
26 changes: 24 additions & 2 deletions internal/service/glue/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,35 @@ func FindDevEndpointByName(conn *glue.Glue, name string) (*glue.DevEndpoint, err
}

if output == nil || output.DevEndpoint == nil {
return nil, tfresource.NewEmptyResultError(input)
}

return output.DevEndpoint, nil
}

func FindJobByName(conn *glue.Glue, name string) (*glue.Job, error) {
input := &glue.GetJobInput{
JobName: aws.String(name),
}

output, err := conn.GetJob(input)

if tfawserr.ErrCodeEquals(err, glue.ErrCodeEntityNotFoundException) {
return nil, &resource.NotFoundError{
Message: "Empty result",
LastError: err,
LastRequest: input,
}
}

return output.DevEndpoint, nil
if err != nil {
return nil, err
}

if output == nil || output.Job == nil {
return nil, tfresource.NewEmptyResultError(input)
}

return output.Job, nil
}

// FindTableByName returns the Table corresponding to the specified name.
Expand Down
Loading