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_app - new resource #17251

Merged
merged 35 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
77f99c3
fix user profile destory check
DrFaust92 Jan 21, 2021
4c8e8a5
domain - add support for image version argument in resource spec block
DrFaust92 Jan 21, 2021
49fb869
app new resource initial commit
DrFaust92 Jan 21, 2021
d6c064b
use domain_id
DrFaust92 Jan 21, 2021
80ad1a7
fix app type
DrFaust92 Jan 21, 2021
e346170
fix
DrFaust92 Jan 21, 2021
fbbaaea
add tests for resource spec
DrFaust92 Jan 21, 2021
ddb63bd
support sweeper
DrFaust92 Jan 22, 2021
45b94a9
fix domain sweeper
DrFaust92 Jan 22, 2021
5e2718b
app basic test
DrFaust92 Jan 22, 2021
9090fe5
image name computed + remove image tests
DrFaust92 Jan 22, 2021
f03d1a3
domain docs
DrFaust92 Jan 22, 2021
6b93621
app docs
DrFaust92 Jan 22, 2021
745c59e
fmt
DrFaust92 Jan 22, 2021
2b8c27d
rename
DrFaust92 Jan 22, 2021
36edcad
simplify error on delete check
DrFaust92 Jan 22, 2021
29d480e
add changelog file
DrFaust92 Jan 22, 2021
21d24f6
dns
DrFaust92 Jan 23, 2021
03b8c2d
changes to domain based on app image config
DrFaust92 Jan 28, 2021
02c4050
sweeper
DrFaust92 Jan 28, 2021
50bae9b
revert image version arn
DrFaust92 Jan 29, 2021
4d7a226
fmt
DrFaust92 Jan 29, 2021
ef161d9
fmt
DrFaust92 Jan 29, 2021
67c53f1
remove acctest item from changelog
DrFaust92 Jan 29, 2021
1c4612b
serialize app tests
DrFaust92 Feb 4, 2021
c12b937
serialize sagemaker domain tests
DrFaust92 Feb 4, 2021
54e0181
lint
DrFaust92 Feb 4, 2021
7eef33f
de-parallelize
DrFaust92 Feb 4, 2021
e47ce81
comment
DrFaust92 Feb 4, 2021
1c32206
misspel
DrFaust92 Feb 4, 2021
4064d3d
mispell 2
DrFaust92 Feb 4, 2021
1fb7275
plural
DrFaust92 Feb 4, 2021
08cba74
wait for update to finish
DrFaust92 Feb 4, 2021
ddf76f9
changelog
DrFaust92 Feb 4, 2021
36dfddc
wait for user profile update to finish
DrFaust92 Feb 5, 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
15 changes: 15 additions & 0 deletions .changelog/17251.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```release-note:new-resource
aws_sagemaker_app
```

```release-note:enhancement
resource/aws_sagemaker_domain: Make `default_resource_spec` optional for the `tensor_board_app_settings`, `jupyter_server_app_settings` and `kernel_gateway_app_settings` config blocks.
```

```release-note:bug
resource/aws_sagemaker_domain: Wait for update to finish.
```

```release-note:bug
resource/aws_sagemaker_user_profile: Wait for update to finish.
```
22 changes: 22 additions & 0 deletions aws/internal/service/sagemaker/finder/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,25 @@ func AppImageConfigByName(conn *sagemaker.SageMaker, appImageConfigID string) (*

return output, nil
}

// AppByName returns the domain corresponding to the specified domain id.
// Returns nil if no domain is found.
func AppByName(conn *sagemaker.SageMaker, domainID, userProfileName, appType, appName string) (*sagemaker.DescribeAppOutput, error) {
input := &sagemaker.DescribeAppInput{
DomainId: aws.String(domainID),
UserProfileName: aws.String(userProfileName),
AppType: aws.String(appType),
AppName: aws.String(appName),
}

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

if output == nil {
return nil, nil
}

return output, nil
}
29 changes: 29 additions & 0 deletions aws/internal/service/sagemaker/waiter/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
SagemakerFeatureGroupStatusUnknown = "Unknown"
SagemakerUserProfileStatusNotFound = "NotFound"
SagemakerModelPackageGroupStatusNotFound = "NotFound"
SagemakerAppStatusNotFound = "NotFound"
)

// NotebookInstanceStatus fetches the NotebookInstance and its Status
Expand Down Expand Up @@ -201,3 +202,31 @@ func UserProfileStatus(conn *sagemaker.SageMaker, domainID, userProfileName stri
return output, aws.StringValue(output.Status), nil
}
}

// AppStatus fetches the App and its Status
func AppStatus(conn *sagemaker.SageMaker, domainID, userProfileName, appType, appName string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
input := &sagemaker.DescribeAppInput{
DomainId: aws.String(domainID),
UserProfileName: aws.String(userProfileName),
AppType: aws.String(appType),
AppName: aws.String(appName),
}

output, err := conn.DescribeApp(input)

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

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

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

return output, aws.StringValue(output.Status), nil
}
}
46 changes: 46 additions & 0 deletions aws/internal/service/sagemaker/waiter/waiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const (
FeatureGroupDeletedTimeout = 10 * time.Minute
UserProfileInServiceTimeout = 10 * time.Minute
UserProfileDeletedTimeout = 10 * time.Minute
AppInServiceTimeout = 10 * time.Minute
AppDeletedTimeout = 10 * time.Minute
)

// NotebookInstanceInService waits for a NotebookInstance to return InService
Expand Down Expand Up @@ -213,6 +215,7 @@ func DomainInService(conn *sagemaker.SageMaker, domainID string) (*sagemaker.Des
Pending: []string{
SagemakerDomainStatusNotFound,
sagemaker.DomainStatusPending,
sagemaker.DomainStatusUpdating,
},
Target: []string{sagemaker.DomainStatusInService},
Refresh: DomainStatus(conn, domainID),
Expand Down Expand Up @@ -325,3 +328,46 @@ func UserProfileDeleted(conn *sagemaker.SageMaker, domainID, userProfileName str

return nil, err
}

// AppInService waits for a App to return InService
func AppInService(conn *sagemaker.SageMaker, domainID, userProfileName, appType, appName string) (*sagemaker.DescribeAppOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{
SagemakerAppStatusNotFound,
sagemaker.AppStatusPending,
},
Target: []string{sagemaker.AppStatusInService},
Refresh: AppStatus(conn, domainID, userProfileName, appType, appName),
Timeout: AppInServiceTimeout,
}

outputRaw, err := stateConf.WaitForState()

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

return nil, err
}

// AppDeleted waits for a App to return Deleted
func AppDeleted(conn *sagemaker.SageMaker, domainID, userProfileName, appType, appName string) (*sagemaker.DescribeAppOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{
sagemaker.AppStatusDeleting,
},
Target: []string{
sagemaker.AppStatusDeleted,
},
Refresh: AppStatus(conn, domainID, userProfileName, appType, appName),
Timeout: AppDeletedTimeout,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*sagemaker.DescribeAppOutput); 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 @@ -895,6 +895,7 @@ func Provider() *schema.Provider {
"aws_route_table": resourceAwsRouteTable(),
"aws_default_route_table": resourceAwsDefaultRouteTable(),
"aws_route_table_association": resourceAwsRouteTableAssociation(),
"aws_sagemaker_app": resourceAwsSagemakerApp(),
"aws_sagemaker_app_image_config": resourceAwsSagemakerAppImageConfig(),
"aws_sagemaker_code_repository": resourceAwsSagemakerCodeRepository(),
"aws_sagemaker_domain": resourceAwsSagemakerDomain(),
Expand Down
Loading