本文整理匯總了Golang中github.com/aws/aws-sdk-go/service/ecs.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewCustomResourceProvisioner
// NewCustomResourceProvisioner returns a new CustomResourceProvisioner with an
// sqs client configured from config.
func NewCustomResourceProvisioner(db *sql.DB, config client.ConfigProvider) *CustomResourceProvisioner {
p := &CustomResourceProvisioner{
Provisioners: make(map[string]customresources.Provisioner),
sendResponse: customresources.SendResponse,
sqs: sqs.New(config),
}
p.add("Custom::InstancePort", &InstancePortsProvisioner{
ports: lb.NewDBPortAllocator(db),
})
p.add("Custom::ECSService", &ECSServiceResource{
ecs: ecs.New(config),
})
store := &dbEnvironmentStore{db}
p.add("Custom::ECSEnvironment", newECSEnvironmentProvisioner(&ECSEnvironmentResource{
environmentStore: store,
}))
p.add("Custom::ECSTaskDefinition", newECSTaskDefinitionProvisioner(&ECSTaskDefinitionResource{
ecs: ecs.New(config),
environmentStore: store,
}))
return p
}
示例2: init
func init() {
if iid, err := ec2.GetInstanceIdentityDocument(); err == nil {
ECS = ecs.New(&aws.Config{Region: iid.Region})
} else {
ECS = ecs.New(nil)
}
Cluster = "ecs-functional-tests"
if envCluster := os.Getenv("ECS_CLUSTER"); envCluster != "" {
Cluster = envCluster
}
}
示例3: ExampleECS_DescribeTasks
func ExampleECS_DescribeTasks() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := ecs.New(sess)
params := &ecs.DescribeTasksInput{
Tasks: []*string{ // Required
aws.String("String"), // Required
// More values...
},
Cluster: aws.String("String"),
}
resp, err := svc.DescribeTasks(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例4: ExampleECS_CreateService
func ExampleECS_CreateService() {
svc := ecs.New(session.New())
params := &ecs.CreateServiceInput{
DesiredCount: aws.Int64(1), // Required
ServiceName: aws.String("String"), // Required
TaskDefinition: aws.String("String"), // Required
ClientToken: aws.String("String"),
Cluster: aws.String("String"),
LoadBalancers: []*ecs.LoadBalancer{
{ // Required
ContainerName: aws.String("String"),
ContainerPort: aws.Int64(1),
LoadBalancerName: aws.String("String"),
},
// More values...
},
Role: aws.String("String"),
}
resp, err := svc.CreateService(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例5: main
func main() {
kingpin.Version("0.0.1")
kingpin.CommandLine.Help = "Dashboard - An AWS ECS visualiser."
kingpin.Parse()
clientECS = ecs.New(&aws.Config{Region: *cliRegion})
r := render.New(render.Options{
Directory: "src/github.com/nickschuch/dashboard/templates",
Asset: Asset,
AssetNames: AssetNames,
IsDevelopment: false,
})
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
params := Cluster{
Name: *cliCluster,
Region: *cliRegion,
Instances: getInstances(),
}
r.HTML(w, http.StatusOK, "cluster", params)
})
http.ListenAndServe(":"+*cliPort, mux)
}
示例6: ExampleECS_UpdateService
func ExampleECS_UpdateService() {
svc := ecs.New(nil)
params := &ecs.UpdateServiceInput{
Service: aws.String("String"), // Required
Cluster: aws.String("String"),
DesiredCount: aws.Long(1),
TaskDefinition: aws.String("String"),
}
resp, err := svc.UpdateService(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例7: init
func init() {
Before("@ecs", func() {
// FIXME remove custom region
World["client"] = ecs.New(smoke.Session,
aws.NewConfig().WithRegion("us-west-2"))
})
}
示例8: ExampleECS_SubmitTaskStateChange
func ExampleECS_SubmitTaskStateChange() {
svc := ecs.New(nil)
params := &ecs.SubmitTaskStateChangeInput{
Cluster: aws.String("String"),
Reason: aws.String("String"),
Status: aws.String("String"),
Task: aws.String("String"),
}
resp, err := svc.SubmitTaskStateChange(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例9: ExampleECS_ListTasks
func ExampleECS_ListTasks() {
svc := ecs.New(session.New())
params := &ecs.ListTasksInput{
Cluster: aws.String("String"),
ContainerInstance: aws.String("String"),
DesiredStatus: aws.String("DesiredStatus"),
Family: aws.String("String"),
MaxResults: aws.Int64(1),
NextToken: aws.String("String"),
ServiceName: aws.String("String"),
StartedBy: aws.String("String"),
}
resp, err := svc.ListTasks(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例10: Exec
// Exec the cmd on the container instances for the cluster.
func Exec(cluster *string, cmd *[]string) {
session := session.New(&aws.Config{Region: aws.String(os.Getenv("AWS_REGION"))})
ecs := ecspkg.New(session)
ec2 := ec2pkg.New(session)
containers := containerInstances(ecs, cluster)
ids := instanceIds(ecs, containers)
ips := privateIps(ec2, ids)
var wg sync.WaitGroup
for _, ip := range ips {
wg.Add(1)
go func(ip string) {
defer wg.Done()
l := log.New(os.Stderr, log.INFO, ip)
args := []string{ip}
args = append(args, *cmd...)
cmd := exec.Command("ssh", args...)
cmd.Stdout = l
cmd.Stderr = l
err := cmd.Run()
if err != nil {
l.Error("failed: %s", err)
}
}(*ip)
}
wg.Wait()
}
示例11: ExampleECS_UpdateContainerAgent
func ExampleECS_UpdateContainerAgent() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := ecs.New(sess)
params := &ecs.UpdateContainerAgentInput{
ContainerInstance: aws.String("String"), // Required
Cluster: aws.String("String"),
}
resp, err := svc.UpdateContainerAgent(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例12: ExampleECS_SubmitTaskStateChange
func ExampleECS_SubmitTaskStateChange() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := ecs.New(sess)
params := &ecs.SubmitTaskStateChangeInput{
Cluster: aws.String("String"),
Reason: aws.String("String"),
Status: aws.String("String"),
Task: aws.String("String"),
}
resp, err := svc.SubmitTaskStateChange(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例13: ExampleECS_SubmitContainerStateChange
func ExampleECS_SubmitContainerStateChange() {
svc := ecs.New(session.New())
params := &ecs.SubmitContainerStateChangeInput{
Cluster: aws.String("String"),
ContainerName: aws.String("String"),
ExitCode: aws.Int64(1),
NetworkBindings: []*ecs.NetworkBinding{
{ // Required
BindIP: aws.String("String"),
ContainerPort: aws.Int64(1),
HostPort: aws.Int64(1),
Protocol: aws.String("TransportProtocol"),
},
// More values...
},
Reason: aws.String("String"),
Status: aws.String("String"),
Task: aws.String("String"),
}
resp, err := svc.SubmitContainerStateChange(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例14: ExampleECS_ListTaskDefinitions
func ExampleECS_ListTaskDefinitions() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := ecs.New(sess)
params := &ecs.ListTaskDefinitionsInput{
FamilyPrefix: aws.String("String"),
MaxResults: aws.Int64(1),
NextToken: aws.String("String"),
Sort: aws.String("SortOrder"),
Status: aws.String("TaskDefinitionStatus"),
}
resp, err := svc.ListTaskDefinitions(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例15: ExampleECS_ListContainerInstances
func ExampleECS_ListContainerInstances() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := ecs.New(sess)
params := &ecs.ListContainerInstancesInput{
Cluster: aws.String("String"),
MaxResults: aws.Int64(1),
NextToken: aws.String("String"),
}
resp, err := svc.ListContainerInstances(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}