// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. package ecs_test import ( "context" "fmt" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/ecs" ) var _ aws.Config // To create a new cluster // // This example creates a cluster in your default region. func ExampleClient_CreateClusterRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.CreateClusterInput{ ClusterName: aws.String("my_cluster"), } req := svc.CreateClusterRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To create a new service // // This example creates a service in your default region called ``ecs-simple-service``. // The service uses the ``hello_world`` task definition and it maintains 10 copies of // that task. func ExampleClient_CreateServiceRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.CreateServiceInput{ DesiredCount: aws.Int64(10), ServiceName: aws.String("ecs-simple-service"), TaskDefinition: aws.String("hello_world"), } req := svc.CreateServiceRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeUnsupportedFeatureException: fmt.Println(ecs.ErrCodeUnsupportedFeatureException, aerr.Error()) case ecs.ErrCodePlatformUnknownException: fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) case ecs.ErrCodeAccessDeniedException: fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To create a new service behind a load balancer // // This example creates a service in your default region called ``ecs-simple-service-elb``. // The service uses the ``ecs-demo`` task definition and it maintains 10 copies of that // task. You must reference an existing load balancer in the same region by its name. func ExampleClient_CreateServiceRequest_shared01() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.CreateServiceInput{ DesiredCount: aws.Int64(10), LoadBalancers: []ecs.LoadBalancer{ { ContainerName: aws.String("simple-app"), ContainerPort: aws.Int64(80), LoadBalancerName: aws.String("EC2Contai-EcsElast-15DCDAURT3ZO2"), }, }, Role: aws.String("ecsServiceRole"), ServiceName: aws.String("ecs-simple-service-elb"), TaskDefinition: aws.String("console-sample-app-static"), } req := svc.CreateServiceRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeUnsupportedFeatureException: fmt.Println(ecs.ErrCodeUnsupportedFeatureException, aerr.Error()) case ecs.ErrCodePlatformUnknownException: fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) case ecs.ErrCodeAccessDeniedException: fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To delete your account setting // // This example deletes the account setting for your user for the specified resource // type. func ExampleClient_DeleteAccountSettingRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.DeleteAccountSettingInput{ Name: ecs.SettingNameServiceLongArnFormat, } req := svc.DeleteAccountSettingRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To delete the account settings for a specific IAM user or IAM role // // This example deletes the account setting for a specific IAM user or IAM role for // the specified resource type. Only the root user can view or modify the account settings // for another user. func ExampleClient_DeleteAccountSettingRequest_shared01() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.DeleteAccountSettingInput{ Name: ecs.SettingNameContainerInstanceLongArnFormat, PrincipalArn: aws.String("arn:aws:iam:::user/principalName"), } req := svc.DeleteAccountSettingRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To delete an empty cluster // // This example deletes an empty cluster in your default region. func ExampleClient_DeleteClusterRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.DeleteClusterInput{ Cluster: aws.String("my_cluster"), } req := svc.DeleteClusterRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeClusterContainsContainerInstancesException: fmt.Println(ecs.ErrCodeClusterContainsContainerInstancesException, aerr.Error()) case ecs.ErrCodeClusterContainsServicesException: fmt.Println(ecs.ErrCodeClusterContainsServicesException, aerr.Error()) case ecs.ErrCodeClusterContainsTasksException: fmt.Println(ecs.ErrCodeClusterContainsTasksException, aerr.Error()) case ecs.ErrCodeUpdateInProgressException: fmt.Println(ecs.ErrCodeUpdateInProgressException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To delete a service // // This example deletes the my-http-service service. The service must have a desired // count and running count of 0 before you can delete it. func ExampleClient_DeleteServiceRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.DeleteServiceInput{ Service: aws.String("my-http-service"), } req := svc.DeleteServiceRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotFoundException: fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To deregister a container instance from a cluster // // This example deregisters a container instance from the specified cluster in your // default region. If there are still tasks running on the container instance, you must // either stop those tasks before deregistering, or use the force option. func ExampleClient_DeregisterContainerInstanceRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.DeregisterContainerInstanceInput{ Cluster: aws.String("default"), ContainerInstance: aws.String("container_instance_UUID"), Force: aws.Bool(true), } req := svc.DeregisterContainerInstanceRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To describe a cluster // // This example provides a description of the specified cluster in your default region. func ExampleClient_DescribeClustersRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.DescribeClustersInput{ Clusters: []string{ "default", }, } req := svc.DescribeClustersRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To describe container instance // // This example provides a description of the specified container instance in your default // region, using the container instance UUID as an identifier. func ExampleClient_DescribeContainerInstancesRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.DescribeContainerInstancesInput{ Cluster: aws.String("default"), ContainerInstances: []string{ "f2756532-8f13-4d53-87c9-aed50dc94cd7", }, } req := svc.DescribeContainerInstancesRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To describe a service // // This example provides descriptive information about the service named ``ecs-simple-service``. func ExampleClient_DescribeServicesRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.DescribeServicesInput{ Services: []string{ "ecs-simple-service", }, } req := svc.DescribeServicesRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To describe a task definition // // This example provides a description of the specified task definition. func ExampleClient_DescribeTaskDefinitionRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.DescribeTaskDefinitionInput{ TaskDefinition: aws.String("hello_world:8"), } req := svc.DescribeTaskDefinitionRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To describe a task // // This example provides a description of the specified task, using the task UUID as // an identifier. func ExampleClient_DescribeTasksRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.DescribeTasksInput{ Tasks: []string{ "c5cba4eb-5dad-405e-96db-71ef8eefe6a8", }, } req := svc.DescribeTasksRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To view your effective account settings // // This example displays the effective account settings for your account. func ExampleClient_ListAccountSettingsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.ListAccountSettingsInput{ EffectiveSettings: aws.Bool(true), } req := svc.ListAccountSettingsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To view the effective account settings for a specific IAM user or IAM role // // This example displays the effective account settings for the specified user or role. func ExampleClient_ListAccountSettingsRequest_shared01() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.ListAccountSettingsInput{ EffectiveSettings: aws.Bool(true), PrincipalArn: aws.String("arn:aws:iam:::user/principalName"), } req := svc.ListAccountSettingsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To list your available clusters // // This example lists all of your available clusters in your default region. func ExampleClient_ListClustersRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.ListClustersInput{} req := svc.ListClustersRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To list your available container instances in a cluster // // This example lists all of your available container instances in the specified cluster // in your default region. func ExampleClient_ListContainerInstancesRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.ListContainerInstancesInput{ Cluster: aws.String("default"), } req := svc.ListContainerInstancesRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To list the services in a cluster // // This example lists the services running in the default cluster for an account. func ExampleClient_ListServicesRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.ListServicesInput{} req := svc.ListServicesRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To list the tags for a cluster. // // This example lists the tags for the 'dev' cluster. func ExampleClient_ListTagsForResourceRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.ListTagsForResourceInput{ ResourceArn: aws.String("arn:aws:ecs:region:aws_account_id:cluster/dev"), } req := svc.ListTagsForResourceRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To list your registered task definition families // // This example lists all of your registered task definition families. func ExampleClient_ListTaskDefinitionFamiliesRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.ListTaskDefinitionFamiliesInput{} req := svc.ListTaskDefinitionFamiliesRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To filter your registered task definition families // // This example lists the task definition revisions that start with "hpcc". func ExampleClient_ListTaskDefinitionFamiliesRequest_shared01() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.ListTaskDefinitionFamiliesInput{ FamilyPrefix: aws.String("hpcc"), } req := svc.ListTaskDefinitionFamiliesRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To list your registered task definitions // // This example lists all of your registered task definitions. func ExampleClient_ListTaskDefinitionsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.ListTaskDefinitionsInput{} req := svc.ListTaskDefinitionsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To list the registered task definitions in a family // // This example lists the task definition revisions of a specified family. func ExampleClient_ListTaskDefinitionsRequest_shared01() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.ListTaskDefinitionsInput{ FamilyPrefix: aws.String("wordpress"), } req := svc.ListTaskDefinitionsRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To list the tasks in a cluster // // This example lists all of the tasks in a cluster. func ExampleClient_ListTasksRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.ListTasksInput{ Cluster: aws.String("default"), } req := svc.ListTasksRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotFoundException: fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To list the tasks on a particular container instance // // This example lists the tasks of a specified container instance. Specifying a ``containerInstance`` // value limits the results to tasks that belong to that container instance. func ExampleClient_ListTasksRequest_shared01() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.ListTasksInput{ Cluster: aws.String("default"), ContainerInstance: aws.String("f6bbb147-5370-4ace-8c73-c7181ded911f"), } req := svc.ListTasksRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotFoundException: fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To modify your account settings // // This example modifies your account settings to opt in to the new ARN and resource // ID format for Amazon ECS services. If you’re using this command as the root user, // then changes apply to the entire AWS account, unless an IAM user or role explicitly // overrides these settings for themselves. func ExampleClient_PutAccountSettingRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.PutAccountSettingInput{ Name: ecs.SettingNameServiceLongArnFormat, Value: aws.String("enabled"), } req := svc.PutAccountSettingRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To modify the account settings for a specific IAM user or IAM role // // This example modifies the account setting for a specific IAM user or IAM role to // opt in to the new ARN and resource ID format for Amazon ECS container instances. // If you’re using this command as the root user, then changes apply to the entire // AWS account, unless an IAM user or role explicitly overrides these settings for themselves. func ExampleClient_PutAccountSettingRequest_shared01() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.PutAccountSettingInput{ Name: ecs.SettingNameContainerInstanceLongArnFormat, PrincipalArn: aws.String("arn:aws:iam:::user/principalName"), Value: aws.String("enabled"), } req := svc.PutAccountSettingRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To modify the default account settings for all IAM users or roles on an account // // This example modifies the default account setting for the specified resource for // all IAM users or roles on an account. These changes apply to the entire AWS account, // unless an IAM user or role explicitly overrides these settings for themselves. func ExampleClient_PutAccountSettingDefaultRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.PutAccountSettingDefaultInput{ Name: ecs.SettingNameServiceLongArnFormat, Value: aws.String("enabled"), } req := svc.PutAccountSettingDefaultRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To register a task definition // // This example registers a task definition to the specified family. func ExampleClient_RegisterTaskDefinitionRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.RegisterTaskDefinitionInput{ ContainerDefinitions: []ecs.ContainerDefinition{ { Command: []string{ "sleep", "360", }, Cpu: aws.Int64(10), Essential: aws.Bool(true), Image: aws.String("busybox"), Memory: aws.Int64(10), Name: aws.String("sleep"), }, }, Family: aws.String("sleep360"), TaskRoleArn: aws.String(""), } req := svc.RegisterTaskDefinitionRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To run a task on your default cluster // // This example runs the specified task definition on your default cluster. func ExampleClient_RunTaskRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.RunTaskInput{ Cluster: aws.String("default"), TaskDefinition: aws.String("sleep360:1"), } req := svc.RunTaskRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeUnsupportedFeatureException: fmt.Println(ecs.ErrCodeUnsupportedFeatureException, aerr.Error()) case ecs.ErrCodePlatformUnknownException: fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) case ecs.ErrCodeAccessDeniedException: fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) case ecs.ErrCodeBlockedException: fmt.Println(ecs.ErrCodeBlockedException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To tag a cluster. // // This example tags the 'dev' cluster with key 'team' and value 'dev'. func ExampleClient_TagResourceRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.TagResourceInput{ ResourceArn: aws.String("arn:aws:ecs:region:aws_account_id:cluster/dev"), Tags: []ecs.Tag{ { Key: aws.String("team"), Value: aws.String("dev"), }, }, } req := svc.TagResourceRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeResourceNotFoundException: fmt.Println(ecs.ErrCodeResourceNotFoundException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To untag a cluster. // // This example deletes the 'team' tag from the 'dev' cluster. func ExampleClient_UntagResourceRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.UntagResourceInput{ ResourceArn: aws.String("arn:aws:ecs:region:aws_account_id:cluster/dev"), TagKeys: []string{ "team", }, } req := svc.UntagResourceRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeResourceNotFoundException: fmt.Println(ecs.ErrCodeResourceNotFoundException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To change the task definition used in a service // // This example updates the my-http-service service to use the amazon-ecs-sample task // definition. func ExampleClient_UpdateServiceRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.UpdateServiceInput{ Service: aws.String("my-http-service"), TaskDefinition: aws.String("amazon-ecs-sample"), } req := svc.UpdateServiceRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotFoundException: fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotActiveException: fmt.Println(ecs.ErrCodeServiceNotActiveException, aerr.Error()) case ecs.ErrCodePlatformUnknownException: fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) case ecs.ErrCodeAccessDeniedException: fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To change the number of tasks in a service // // This example updates the desired count of the my-http-service service to 10. func ExampleClient_UpdateServiceRequest_shared01() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := ecs.New(cfg) input := &ecs.UpdateServiceInput{ DesiredCount: aws.Int64(10), Service: aws.String("my-http-service"), } req := svc.UpdateServiceRequest(input) result, err := req.Send(context.Background()) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case ecs.ErrCodeServerException: fmt.Println(ecs.ErrCodeServerException, aerr.Error()) case ecs.ErrCodeException: fmt.Println(ecs.ErrCodeException, aerr.Error()) case ecs.ErrCodeInvalidParameterException: fmt.Println(ecs.ErrCodeInvalidParameterException, aerr.Error()) case ecs.ErrCodeClusterNotFoundException: fmt.Println(ecs.ErrCodeClusterNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotFoundException: fmt.Println(ecs.ErrCodeServiceNotFoundException, aerr.Error()) case ecs.ErrCodeServiceNotActiveException: fmt.Println(ecs.ErrCodeServiceNotActiveException, aerr.Error()) case ecs.ErrCodePlatformUnknownException: fmt.Println(ecs.ErrCodePlatformUnknownException, aerr.Error()) case ecs.ErrCodePlatformTaskDefinitionIncompatibilityException: fmt.Println(ecs.ErrCodePlatformTaskDefinitionIncompatibilityException, aerr.Error()) case ecs.ErrCodeAccessDeniedException: fmt.Println(ecs.ErrCodeAccessDeniedException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) }