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

[WIP] Sagemaker Notebook DirectInternetAccess support #7884

Closed
wants to merge 0 commits into from
Closed

[WIP] Sagemaker Notebook DirectInternetAccess support #7884

wants to merge 0 commits into from

Conversation

bcatubig
Copy link
Contributor

@bcatubig bcatubig commented Mar 10, 2019

Enhancement #2999

Changes proposed in this pull request:

  • Allow user to disable internet access to notebook

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Output from acceptance testing:

Currently dealing with destroy issues...

make testacc TESTARGS='-run=TestAccAWSSagemakerNotebookInstance_directInternetAccess'

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSSagemakerNotebookInstance_directInternetAccess -timeout 120m
=== RUN   TestAccAWSSagemakerNotebookInstance_directInternetAccess
=== PAUSE TestAccAWSSagemakerNotebookInstance_directInternetAccess
=== CONT  TestAccAWSSagemakerNotebookInstance_directInternetAccess
--- FAIL: TestAccAWSSagemakerNotebookInstance_directInternetAccess (225.45s)
    testing.go:599: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.
        
        Error: Error applying: 1 error occurred:
                * aws_sagemaker_notebook_instance.foo (destroy): 1 error occurred:
                * aws_sagemaker_notebook_instance.foo: error waiting for sagemaker notebook instance (terraform-testacc-20190311022405872400000001) to stop: RequestError: send request failed
        caused by: Post https://api.sagemaker.us-east-1.amazonaws.com/: read tcp 192.168.1.201:57866->34.201.234.253:443: read: connection reset by peer

@ghost ghost added size/M Managed by automation to categorize the size of a PR. service/sagemaker Issues and PRs that pertain to the sagemaker service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. documentation Introduces or discusses updates to documentation. labels Mar 10, 2019
@bcatubig bcatubig mentioned this pull request Mar 10, 2019
@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Mar 26, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bcatubig 👋 This is looking pretty good. Is there anything else that needs to happen here? Acceptance testing seems to be passing just fine for me, e.g.

--- PASS: TestAccAWSSagemakerNotebookInstance_basic (220.51s)
--- PASS: TestAccAWSSagemakerNotebookInstance_directInternetAccess (295.28s)

cidr_block = "10.0.1.0/24"

tags = {
Name = "Main"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: To prevent confusion for anyone running the acceptance testing in their own accounts it might be good to make this Name tags more descriptive for the test configurations in case the testing leaves dangling resources, e.g.

Suggested change
Name = "Main"
Name = "tf-acc-test-sagemaker-notebook-instance-direct-internet-access"

aws/resource_aws_sagemaker_notebook_instance_test.go Outdated Show resolved Hide resolved
aws/resource_aws_sagemaker_notebook_instance.go Outdated Show resolved Hide resolved
@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Mar 26, 2019
@bcatubig
Copy link
Contributor Author

Thanks @bflad -- will make requested changes

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Mar 26, 2019
@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Mar 27, 2019
@bcatubig
Copy link
Contributor Author

Hey @bflad

Feedback implemented

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Mar 31, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost there, @bcatubig! Two little fixes and should be ready to go. 😄

})
}

func TestAccAWSSagemakerNotebookInstance_directInternetAccess_enabled(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this acceptance test is failing while the others pass:

--- FAIL: TestAccAWSSagemakerNotebookInstance_directInternetAccess_enabled (255.12s)
    testing.go:538: Step 0 error: Check failed: Check 3/5 error: DirectInternetAccess not configured correctly: want Enabled got Disabled
--- PASS: TestAccAWSSagemakerNotebookInstance_basic (259.02s)
--- PASS: TestAccAWSSagemakerNotebookInstance_directInternetAccess_disabled (292.10s)
--- PASS: TestAccAWSSagemakerNotebookInstance_tags (296.42s)
--- PASS: TestAccAWSSagemakerNotebookInstance_disappears (314.73s)
--- PASS: TestAccAWSSagemakerNotebookInstance_update (443.07s)

Did you mean to point it to the same direct_internet_access = "Disabled" configuration? The easiest fix might be to parameterize that argument for the configuration:

func testAccAWSSagemakerNotebookInstanceConfigDirectInternetAccess(notebookName, directInternetAccess string) string {
	return fmt.Sprintf(`
resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "main" {
  vpc_id     = "${aws_vpc.main.id}"
  cidr_block = "10.0.1.0/24"
  tags = {
    Name = "tf-acc-test-sagemaker-notebook-instance-direct-internet-access"
  }
}
resource "aws_security_group" "foo" {
  name        = "foo"
  vpc_id      = "${aws_vpc.main.id}"
  description = "foo bar baz"
  tags = {
    Name = "foo_sg"
  }
}
resource "aws_sagemaker_notebook_instance" "foo" {
  name                   = %[1]q
  role_arn               = "${aws_iam_role.foo.arn}"
  instance_type          = "ml.t2.medium"
  subnet_id              = "${aws_subnet.main.id}"
  security_groups        = ["${aws_security_group.foo.id}"]
  direct_internet_access = %[2]q
}
resource "aws_iam_role" "foo" {
  name               = %[1]q
  path               = "/"
  assume_role_policy = "${data.aws_iam_policy_document.assume_role.json}"
}
data "aws_iam_policy_document" "assume_role" {
  statement {
    actions = ["sts:AssumeRole"]
    principals {
      type        = "Service"
      identifiers = ["sagemaker.amazonaws.com"]
    }
  }
}
`, notebookName, directInternetAccess)
}

Then updating the two Config calls:

// in TestAccAWSSagemakerNotebookInstance_directInternetAccess_disabled
Config: testAccAWSSagemakerNotebookInstanceConfigDirectInternetAccess(notebookName, "Disabled"),

// in TestAccAWSSagemakerNotebookInstance_directInternetAccess_enabled
Config: testAccAWSSagemakerNotebookInstanceConfigDirectInternetAccess(notebookName, "Enabled"),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll refactor this

@@ -36,6 +36,7 @@ The following arguments are supported:
* `subnet_id` - (Optional) The VPC subnet ID.
* `security_groups` - (Optional) The associated security groups.
* `kms_key_id` - (Optional) The AWS Key Management Service (AWS KMS) key that Amazon SageMaker uses to encrypt the model artifacts at rest using Amazon S3 server-side encryption.
* `direct_internet_access` - (Optional) Set to `Disabled` to disable internet access to notebook. Requires `subnet_id` to be set.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention this supports Enabled as well (for Terraform modules, etc.)

Suggested change
* `direct_internet_access` - (Optional) Set to `Disabled` to disable internet access to notebook. Requires `subnet_id` to be set.
* `direct_internet_access` - (Optional) Set to `Disabled` to disable internet access to notebook. Requires `subnet_id` to be set. Valid values: `Disabled`, `Enabled`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bflad, is there specific format for parameters that support multiple values?

Ex:

  • foo - (Optional). Foo does a thing. Supported values: Enabled or Disabled

Copy link
Contributor

@bflad bflad Apr 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I lean towards Valid values: one, two but I'm not sure if there is a specific "format". Its more important they are listed in some way.

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Apr 1, 2019
@bcatubig bcatubig closed this Apr 5, 2019
@ghost ghost added size/XS Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Apr 5, 2019
@bcatubig
Copy link
Contributor Author

bcatubig commented Apr 5, 2019

Totally nuked this by accident. Will fix tonight when I have access to my other computer.

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Apr 5, 2019
@rainmanh
Copy link

What is the status for this @bcatubig ?

@chrispruitt
Copy link

@bcatubig is the direct_internet_access option available in any specific version yet? many thanks

@bcatubig
Copy link
Contributor Author

bcatubig commented May 12, 2019 via email

@sworisbreathing
Copy link
Contributor

hi @bcatubig - has there been any movement on fixing up this PR? I'm pretty keen on seeing this config option exposed through terraform.

@bcatubig
Copy link
Contributor Author

Hey @sworisbreathing -- this has been moved to #8618

@ghost
Copy link

ghost commented Nov 3, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/sagemaker Issues and PRs that pertain to the sagemaker service. size/XS Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants