Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Feat/sagemaker #291

Merged
merged 10 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/route53"
"github.com/aws/aws-sdk-go-v2/service/route53domains"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/sagemaker"
s3control "github.com/aws/aws-sdk-go-v2/service/s3control"
"github.com/aws/aws-sdk-go-v2/service/sns"
"github.com/aws/aws-sdk-go-v2/service/sqs"
Expand Down Expand Up @@ -122,6 +123,7 @@ type Services struct {
S3 S3Client
S3Control S3ControlClient
S3Manager S3ManagerClient
SageMaker SageMakerClient
SQS SQSClient
Apigateway ApigatewayClient
Apigatewayv2 Apigatewayv2Client
Expand All @@ -130,6 +132,7 @@ type Services struct {
Waf WafClient
WafV2 WafV2Client
}

type ServicesAccountRegionMap map[string]map[string]*Services

// ServicesManager will hold the entire map of (account X region) services
Expand Down Expand Up @@ -380,6 +383,7 @@ func initServices(region string, c aws.Config) Services {
S3: s3.NewFromConfig(awsCfg),
S3Control: s3control.NewFromConfig(awsCfg),
S3Manager: newS3ManagerFromConfig(awsCfg),
SageMaker: sagemaker.NewFromConfig(awsCfg),
SNS: sns.NewFromConfig(awsCfg),
SQS: sqs.NewFromConfig(awsCfg),
Waf: waf.NewFromConfig(awsCfg),
Expand Down
216 changes: 216 additions & 0 deletions client/mocks/mock_sagemaker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions client/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/route53domains"
"github.com/aws/aws-sdk-go-v2/service/s3"
s3control "github.com/aws/aws-sdk-go-v2/service/s3control"
"github.com/aws/aws-sdk-go-v2/service/sagemaker"
"github.com/aws/aws-sdk-go-v2/service/sns"
"github.com/aws/aws-sdk-go-v2/service/sqs"
"github.com/aws/aws-sdk-go-v2/service/waf"
Expand Down Expand Up @@ -422,3 +423,16 @@ type SQSClient interface {
ListQueues(ctx context.Context, params *sqs.ListQueuesInput, optFns ...func(*sqs.Options)) (*sqs.ListQueuesOutput, error)
ListQueueTags(ctx context.Context, params *sqs.ListQueueTagsInput, optFns ...func(*sqs.Options)) (*sqs.ListQueueTagsOutput, error)
}

//go:generate mockgen -package=mocks -destination=./mocks/mock_sagemaker.go . SageMakerClient
type SageMakerClient interface {
ListNotebookInstances(ctx context.Context, params *sagemaker.ListNotebookInstancesInput, optFns ...func(*sagemaker.Options)) (*sagemaker.ListNotebookInstancesOutput, error)
DescribeNotebookInstance(ctx context.Context, params *sagemaker.DescribeNotebookInstanceInput, optFns ...func(*sagemaker.Options)) (*sagemaker.DescribeNotebookInstanceOutput, error)
ListTags(ctx context.Context, params *sagemaker.ListTagsInput, optFns ...func(*sagemaker.Options)) (*sagemaker.ListTagsOutput, error)
ListModels(ctx context.Context, params *sagemaker.ListModelsInput, optFns ...func(*sagemaker.Options)) (*sagemaker.ListModelsOutput, error)
DescribeModel(ctx context.Context, params *sagemaker.DescribeModelInput, optFns ...func(*sagemaker.Options)) (*sagemaker.DescribeModelOutput, error)
ListEndpointConfigs(ctx context.Context, params *sagemaker.ListEndpointConfigsInput, optFns ...func(*sagemaker.Options)) (*sagemaker.ListEndpointConfigsOutput, error)
DescribeEndpointConfig(ctx context.Context, params *sagemaker.DescribeEndpointConfigInput, optFns ...func(*sagemaker.Options)) (*sagemaker.DescribeEndpointConfigOutput, error)
ListTrainingJobs(ctx context.Context, params *sagemaker.ListTrainingJobsInput, optFns ...func(*sagemaker.Options)) (*sagemaker.ListTrainingJobsOutput, error)
DescribeTrainingJob(ctx context.Context, params *sagemaker.DescribeTrainingJobInput, optFns ...func(*sagemaker.Options)) (*sagemaker.DescribeTrainingJobOutput, error)
}
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/redshift v1.3.0
github.com/aws/aws-sdk-go-v2/service/route53 v1.4.0
github.com/aws/aws-sdk-go-v2/service/s3 v1.19.1
github.com/aws/aws-sdk-go-v2/service/sagemaker v1.19.1
github.com/aws/aws-sdk-go-v2/service/sns v1.1.2
github.com/aws/aws-sdk-go-v2/service/sqs v1.9.1
github.com/aws/aws-sdk-go-v2/service/sts v1.4.1
Expand Down Expand Up @@ -137,7 +138,4 @@ require (
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.0.0 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.1 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.0.1 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/tools v0.1.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ github.com/aws/aws-sdk-go-v2/service/s3 v1.19.1 h1:v7n7a2v9fN+We4Jna/u7+35Fhch5Y
github.com/aws/aws-sdk-go-v2/service/s3 v1.19.1/go.mod h1:wcAYHjbvrLxDNWJmwCgwxudlHIkSLyU2m4Q1tWO6QZw=
github.com/aws/aws-sdk-go-v2/service/s3control v1.14.1 h1:Nmcb6pxJtjJof+mmF9TJvyWuSbzv7sCn5YoK3MAsPek=
github.com/aws/aws-sdk-go-v2/service/s3control v1.14.1/go.mod h1:dTnxIRqR69JUZobQDUh47rlbYe8PzTd0k4o+gDkHeV4=
github.com/aws/aws-sdk-go-v2/service/sagemaker v1.19.1 h1:cy6fUlP94vzD/0VUD3SWGUBfYrOr+zP+ChsTxUtZydQ=
github.com/aws/aws-sdk-go-v2/service/sagemaker v1.19.1/go.mod h1:G9AcXDbGtZVA8XBdmpbVQv1lvmiuk4I9n2MQlp1FJ9k=
github.com/aws/aws-sdk-go-v2/service/sns v1.1.2 h1:1U/FujyBEkNwrvANUcZFuVnAQqy0EAUEGToso5Dcijs=
github.com/aws/aws-sdk-go-v2/service/sns v1.1.2/go.mod h1:/vvAGyo3/TG5CSrJQarIlwzjE6O/DjBIvJTRkpYkvwA=
github.com/aws/aws-sdk-go-v2/service/sqs v1.9.1 h1:8m+6iuSldxMrVQbjHRcWPnUxdpD3RCPtacmFFNkR4Vw=
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package integration_tests

import (
"fmt"
"testing"

"github.com/cloudquery/cq-provider-aws/resources"
providertest "github.com/cloudquery/cq-provider-sdk/provider/testing"
)

func TestIntegrationSageMakerEndpointConfigurations(t *testing.T) {
awsTestIntegrationHelper(t, resources.SagemakerEndpointConfigurations(), []string{"aws_sagemaker_endpoint_configurations.tf", "aws_sagemaker_models.tf"}, func(res *providertest.ResourceIntegrationTestData) providertest.ResourceIntegrationVerification {
return providertest.ResourceIntegrationVerification{
Name: "aws_sagemaker_endpoint_configurations",
ExpectedValues: []providertest.ExpectedValue{
{
Count: 1,
Data: map[string]interface{}{
"name": fmt.Sprintf("sagemaker-endpoint-configuration-%s%s", res.Prefix, res.Suffix),
"tags": map[string]interface{}{
"TestId": res.Suffix,
"Type": "integration_test",
"Name": fmt.Sprintf("sagemaker-endpoint-configuration-%s%s", res.Prefix, res.Suffix),
},
},
},
},
Relations: []*providertest.ResourceIntegrationVerification{
{
Name: "aws_sagemaker_endpoint_configuration_production_variants",
ForeignKeyName: "endpoint_configuration_cq_id",
ExpectedValues: []providertest.ExpectedValue{
{
Count: 1,
Data: map[string]interface{}{
"variant_name": fmt.Sprintf("variant-%s%s", res.Prefix, res.Suffix),
"model_name": fmt.Sprintf("sagemaker-model-%s%s", res.Prefix, res.Suffix),
"initial_instance_count": float64(1),
"instance_type": "ml.t2.medium",
},
},
},
},
},
}
})
}
30 changes: 30 additions & 0 deletions resources/integration_tests/aws_sagemaker_models_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package integration_tests

import (
"fmt"
"testing"

"github.com/cloudquery/cq-provider-aws/resources"
providertest "github.com/cloudquery/cq-provider-sdk/provider/testing"
)

func TestIntegrationSageMakerModels(t *testing.T) {
awsTestIntegrationHelper(t, resources.SagemakerModels(), nil, func(res *providertest.ResourceIntegrationTestData) providertest.ResourceIntegrationVerification {
return providertest.ResourceIntegrationVerification{
Name: "aws_sagemaker_models",
ExpectedValues: []providertest.ExpectedValue{
{
Count: 1,
Data: map[string]interface{}{
"name": fmt.Sprintf("sagemaker-model-%s%s", res.Prefix, res.Suffix),
"tags": map[string]interface{}{
"TestId": res.Suffix,
"Type": "integration_test",
"Name": fmt.Sprintf("sagemaker-model-%s%s", res.Prefix, res.Suffix),
},
},
},
},
}
})
}
Loading