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

r/sagemaker_notebook_instance - add url and network_interface_id attributes #15802

Merged
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
17 changes: 16 additions & 1 deletion aws/resource_aws_sagemaker_notebook_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,14 @@ func resourceAwsSagemakerNotebookInstance() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},

"url": {
Type: schema.TypeString,
Computed: true,
},
"network_interface_id": {
Type: schema.TypeString,
Computed: true,
},
"tags": tagsSchema(),
},
}
Expand Down Expand Up @@ -236,6 +243,14 @@ func resourceAwsSagemakerNotebookInstanceRead(d *schema.ResourceData, meta inter
return fmt.Errorf("error setting default_code_repository for sagemaker notebook instance (%s): %s", d.Id(), err)
}

if err := d.Set("url", notebookInstance.Url); err != nil {
return fmt.Errorf("error setting url for sagemaker notebook instance (%s): %w", d.Id(), err)
}

if err := d.Set("network_interface_id", notebookInstance.NetworkInterfaceId); err != nil {
return fmt.Errorf("error setting network_interface_id for sagemaker notebook instance (%s): %w", d.Id(), err)
}

tags, err := keyvaluetags.SagemakerListTags(conn, aws.StringValue(notebookInstance.NotebookInstanceArn))

if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions aws/resource_aws_sagemaker_notebook_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"log"
"regexp"
"testing"

"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -95,6 +96,7 @@ func TestAccAWSSagemakerNotebookInstance_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "default_code_repository", ""),
resource.TestCheckResourceAttr(resourceName, "security_groups.#", "0"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttrSet(resourceName, "url"),
),
},
{
Expand Down Expand Up @@ -434,6 +436,7 @@ func TestAccAWSSagemakerNotebookInstance_direct_internet_access(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "direct_internet_access", "Disabled"),
resource.TestCheckResourceAttrPair(resourceName, "subnet_id", "aws_subnet.test", "id"),
resource.TestCheckResourceAttr(resourceName, "security_groups.#", "1"),
resource.TestMatchResourceAttr(resourceName, "network_interface_id", regexp.MustCompile("eni-.*")),
),
},
{
Expand All @@ -448,6 +451,7 @@ func TestAccAWSSagemakerNotebookInstance_direct_internet_access(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "direct_internet_access", "Enabled"),
resource.TestCheckResourceAttrPair(resourceName, "subnet_id", "aws_subnet.test", "id"),
resource.TestCheckResourceAttr(resourceName, "security_groups.#", "1"),
resource.TestMatchResourceAttr(resourceName, "network_interface_id", regexp.MustCompile("eni-.*")),
),
},
},
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/sagemaker_notebook_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ The following attributes are exported:

* `id` - The name of the notebook instance.
* `arn` - The Amazon Resource Name (ARN) assigned by AWS to this notebook instance.
* `url` - The URL that you use to connect to the Jupyter notebook that is running in your notebook instance.
* `network_interface_id` - The network interface ID that Amazon SageMaker created at the time of creating the instance. Only available when setting `subnet_id`.

## Import

Expand Down