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_domain - new resource #16077

Merged
merged 33 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
05bc4d3
add resource
DrFaust92 Nov 1, 2020
4c9dc3d
add to provider
DrFaust92 Nov 1, 2020
bdc8be9
add waiters
DrFaust92 Nov 1, 2020
97b11e2
fix argument name
DrFaust92 Nov 1, 2020
4199594
add tests
DrFaust92 Nov 1, 2020
bedbee6
domain tests
DrFaust92 Nov 3, 2020
0a8f266
move efs delete to tests
DrFaust92 Nov 6, 2020
491c676
add tags test
DrFaust92 Nov 6, 2020
2706ac0
add sg test
DrFaust92 Nov 6, 2020
f75acff
add kms test
DrFaust92 Nov 6, 2020
7f964e8
fix sg name
DrFaust92 Nov 6, 2020
f390f8c
docs
DrFaust92 Nov 6, 2020
979339c
fmt
DrFaust92 Nov 6, 2020
cbd61bd
sg test fmt
DrFaust92 Nov 6, 2020
0058226
delete implict sgs
DrFaust92 Nov 6, 2020
2f4fedf
tests are passing
DrFaust92 Nov 7, 2020
8d67e97
fix tags
DrFaust92 Nov 7, 2020
71b6385
fix filter for implict sgs
DrFaust92 Nov 7, 2020
6d1b9ba
remove kms key attributes and tests
DrFaust92 Nov 7, 2020
6c407f5
share settings
DrFaust92 Nov 7, 2020
7f98573
fix basic test
DrFaust92 Nov 7, 2020
d810be1
fix default_resource_spec
DrFaust92 Nov 7, 2020
dd67c32
force new
DrFaust92 Nov 7, 2020
07a393d
add last tests
DrFaust92 Nov 7, 2020
8806d20
fmt
DrFaust92 Nov 8, 2020
4cf57ad
Apply suggestions from code review
DrFaust92 Nov 9, 2020
2017162
add custom image
DrFaust92 Nov 9, 2020
ff805a6
add with image test
DrFaust92 Jan 9, 2021
d0f80f9
fmt
DrFaust92 Jan 9, 2021
6ae4fb4
fix non existent argument + add kms key support
DrFaust92 Jan 9, 2021
abdcf86
restore vpc id
DrFaust92 Jan 9, 2021
54a577a
missed a spot
DrFaust92 Jan 9, 2021
f2aabe6
remove computed from kms
DrFaust92 Jan 9, 2021
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
19 changes: 19 additions & 0 deletions aws/internal/service/sagemaker/finder/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,22 @@ func ImageByName(conn *sagemaker.SageMaker, name string) (*sagemaker.DescribeIma

return output, nil
}

// DomainByName returns the domain corresponding to the specified domain id.
// Returns nil if no domain is found.
func DomainByName(conn *sagemaker.SageMaker, domainID string) (*sagemaker.DescribeDomainOutput, error) {
input := &sagemaker.DescribeDomainInput{
DomainId: aws.String(domainID),
}

output, err := conn.DescribeDomain(input)
if err != nil {
return nil, err
}

if output == nil {
return nil, nil
}

return output, nil
}
26 changes: 26 additions & 0 deletions aws/internal/service/sagemaker/waiter/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (
SagemakerNotebookInstanceStatusNotFound = "NotFound"
SagemakerImageStatusNotFound = "NotFound"
SagemakerImageStatusFailed = "Failed"
SagemakerDomainStatusNotFound = "NotFound"
)

// NotebookInstanceStatus fetches the NotebookInstance and its Status
Expand Down Expand Up @@ -68,3 +69,28 @@ func ImageStatus(conn *sagemaker.SageMaker, name string) resource.StateRefreshFu
return output, aws.StringValue(output.ImageStatus), nil
}
}

// DomainStatus fetches the Domain and its Status
func DomainStatus(conn *sagemaker.SageMaker, domainID string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
input := &sagemaker.DescribeDomainInput{
DomainId: aws.String(domainID),
}

output, err := conn.DescribeDomain(input)

if tfawserr.ErrMessageContains(err, "ValidationException", "RecordNotFound") {
return nil, SagemakerDomainStatusNotFound, nil
}

if err != nil {
return nil, sagemaker.DomainStatusFailed, err
}

if output == nil {
return nil, SagemakerDomainStatusNotFound, nil
}

return output, aws.StringValue(output.Status), nil
}
}
43 changes: 43 additions & 0 deletions aws/internal/service/sagemaker/waiter/waiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const (
NotebookInstanceDeletedTimeout = 10 * time.Minute
ImageCreatedTimeout = 10 * time.Minute
ImageDeletedTimeout = 10 * time.Minute
DomainInServiceTimeout = 10 * time.Minute
DomainDeletedTimeout = 10 * time.Minute
)

// NotebookInstanceInService waits for a NotebookInstance to return InService
Expand Down Expand Up @@ -117,3 +119,44 @@ func ImageDeleted(conn *sagemaker.SageMaker, name string) (*sagemaker.DescribeIm

return nil, err
}

// DomainInService waits for a Domain to return InService
func DomainInService(conn *sagemaker.SageMaker, domainID string) (*sagemaker.DescribeDomainOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{
SagemakerDomainStatusNotFound,
sagemaker.DomainStatusPending,
},
Target: []string{sagemaker.DomainStatusInService},
Refresh: DomainStatus(conn, domainID),
Timeout: DomainInServiceTimeout,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*sagemaker.DescribeDomainOutput); ok {
return output, err
}

return nil, err
}

// DomainDeleted waits for a Domain to return Deleted
func DomainDeleted(conn *sagemaker.SageMaker, domainID string) (*sagemaker.DescribeDomainOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{
sagemaker.DomainStatusDeleting,
},
Target: []string{},
Refresh: DomainStatus(conn, domainID),
Timeout: DomainDeletedTimeout,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*sagemaker.DescribeDomainOutput); ok {
return output, err
}

return nil, err
}
1 change: 1 addition & 0 deletions aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,7 @@ func Provider() *schema.Provider {
"aws_default_route_table": resourceAwsDefaultRouteTable(),
"aws_route_table_association": resourceAwsRouteTableAssociation(),
"aws_sagemaker_code_repository": resourceAwsSagemakerCodeRepository(),
"aws_sagemaker_domain": resourceAwsSagemakerDomain(),
"aws_sagemaker_endpoint_configuration": resourceAwsSagemakerEndpointConfiguration(),
"aws_sagemaker_image": resourceAwsSagemakerImage(),
"aws_sagemaker_endpoint": resourceAwsSagemakerEndpoint(),
Expand Down
Loading