本文整理汇总了Golang中github.com/convox/cli/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/cloudformation.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ExampleCloudFormation_ValidateTemplate
func ExampleCloudFormation_ValidateTemplate() {
svc := cloudformation.New(nil)
params := &cloudformation.ValidateTemplateInput{
TemplateBody: aws.String("TemplateBody"),
TemplateURL: aws.String("TemplateURL"),
}
resp, err := svc.ValidateTemplate(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))
}
开发者ID:nguyendangminh,项目名称:cli,代码行数:27,代码来源:examples_test.go
示例2: ExampleCloudFormation_SignalResource
func ExampleCloudFormation_SignalResource() {
svc := cloudformation.New(nil)
params := &cloudformation.SignalResourceInput{
LogicalResourceID: aws.String("LogicalResourceId"), // Required
StackName: aws.String("StackNameOrId"), // Required
Status: aws.String("ResourceSignalStatus"), // Required
UniqueID: aws.String("ResourceSignalUniqueId"), // Required
}
resp, err := svc.SignalResource(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))
}
开发者ID:nguyendangminh,项目名称:cli,代码行数:29,代码来源:examples_test.go
示例3: ExampleCloudFormation_EstimateTemplateCost
func ExampleCloudFormation_EstimateTemplateCost() {
svc := cloudformation.New(nil)
params := &cloudformation.EstimateTemplateCostInput{
Parameters: []*cloudformation.Parameter{
{ // Required
ParameterKey: aws.String("ParameterKey"),
ParameterValue: aws.String("ParameterValue"),
UsePreviousValue: aws.Boolean(true),
},
// More values...
},
TemplateBody: aws.String("TemplateBody"),
TemplateURL: aws.String("TemplateURL"),
}
resp, err := svc.EstimateTemplateCost(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))
}
开发者ID:nguyendangminh,项目名称:cli,代码行数:35,代码来源:examples_test.go
示例4: ExampleCloudFormation_ListStacks
func ExampleCloudFormation_ListStacks() {
svc := cloudformation.New(nil)
params := &cloudformation.ListStacksInput{
NextToken: aws.String("NextToken"),
StackStatusFilter: []*string{
aws.String("StackStatus"), // Required
// More values...
},
}
resp, err := svc.ListStacks(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))
}
开发者ID:nguyendangminh,项目名称:cli,代码行数:30,代码来源:examples_test.go
示例5: ExampleCloudFormation_CreateStack
func ExampleCloudFormation_CreateStack() {
svc := cloudformation.New(nil)
params := &cloudformation.CreateStackInput{
StackName: aws.String("StackName"), // Required
Capabilities: []*string{
aws.String("Capability"), // Required
// More values...
},
DisableRollback: aws.Boolean(true),
NotificationARNs: []*string{
aws.String("NotificationARN"), // Required
// More values...
},
OnFailure: aws.String("OnFailure"),
Parameters: []*cloudformation.Parameter{
{ // Required
ParameterKey: aws.String("ParameterKey"),
ParameterValue: aws.String("ParameterValue"),
UsePreviousValue: aws.Boolean(true),
},
// More values...
},
StackPolicyBody: aws.String("StackPolicyBody"),
StackPolicyURL: aws.String("StackPolicyURL"),
Tags: []*cloudformation.Tag{
{ // Required
Key: aws.String("TagKey"),
Value: aws.String("TagValue"),
},
// More values...
},
TemplateBody: aws.String("TemplateBody"),
TemplateURL: aws.String("TemplateURL"),
TimeoutInMinutes: aws.Long(1),
}
resp, err := svc.CreateStack(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))
}
开发者ID:nguyendangminh,项目名称:cli,代码行数:56,代码来源:examples_test.go
示例6: cmdUninstall
func cmdUninstall(c *cli.Context) {
fmt.Println(`
___ ___ ___ __ __ ___ __ _
/'___\ / __'\ /' _ '\/\ \/\ \ / __'\/\ \/'\
/\ \__//\ \_\ \/\ \/\ \ \ \_/ |/\ \_\ \/> </
\ \____\ \____/\ \_\ \_\ \___/ \ \____//\_/\_\
\/____/\/___/ \/_/\/_/\/__/ \/___/ \//\/_/
`)
fmt.Println("This uninstaller needs AWS credentials to uninstall the Convox platform from")
fmt.Println("your AWS account. These credentials will only be used to communicate")
fmt.Println("between this uninstaller running on your computer and the AWS API.")
fmt.Println("")
fmt.Println("We recommend that you create a new set of credentials exclusively for this")
fmt.Println("uninstall process and then delete them once the uninstaller has completed.")
fmt.Println("")
fmt.Println("To generate a new set of AWS credentials go to:")
fmt.Println("https://docs.convox.com/docs/creating-an-iam-user-and-credentials")
fmt.Println("")
reader := bufio.NewReader(os.Stdin)
access := os.Getenv("AWS_ACCESS_KEY_ID")
secret := os.Getenv("AWS_SECRET_ACCESS_KEY")
region := c.String("region")
if access == "" || secret == "" {
var err error
fmt.Print("AWS Access Key: ")
access, err = reader.ReadString('\n')
if err != nil {
stdcli.Error(err)
}
fmt.Print("AWS Secret Access Key: ")
secret, err = reader.ReadString('\n')
if err != nil {
stdcli.Error(err)
}
}
stackName := c.String("stack-name")
fmt.Println("")
fmt.Println("Uninstalling Convox...")
distinctId := randomString(10)
access = strings.TrimSpace(access)
secret = strings.TrimSpace(secret)
CloudFormation := cloudformation.New(&aws.Config{
Region: region,
Credentials: credentials.NewStaticCredentials(access, secret, ""),
})
res, err := CloudFormation.DescribeStacks(&cloudformation.DescribeStacksInput{
StackName: aws.String(stackName),
})
if err != nil {
sendMixpanelEvent(fmt.Sprintf("convox-uninstall-error"), err.Error())
if awsErr, ok := err.(awserr.Error); ok {
if awsErr.Code() == "ValidationError" {
stdcli.Error(fmt.Errorf("Stack %q does not exist.", stackName))
}
}
stdcli.Error(err)
}
stackId := *res.Stacks[0].StackID
_, err = CloudFormation.DeleteStack(&cloudformation.DeleteStackInput{
StackName: aws.String(stackId),
})
if err != nil {
handleError("uninstall", distinctId, err)
return
}
sendMixpanelEvent("convox-uninstall-start", "")
_, err = waitForCompletion(stackId, CloudFormation, true)
if err != nil {
handleError("uninstall", distinctId, err)
return
}
//.........这里部分代码省略.........
开发者ID:ngotnghet,项目名称:cli,代码行数:101,代码来源:install.go
示例7: cmdInstall
func cmdInstall(c *cli.Context) {
region := c.String("region")
if !lambdaRegions[region] {
stdcli.Error(fmt.Errorf("Convox is not currently supported in %s", region))
}
tenancy := "default"
instanceType := c.String("instance-type")
if c.Bool("dedicated") {
tenancy = "dedicated"
if strings.HasPrefix(instanceType, "t2") {
stdcli.Error(fmt.Errorf("t2 instance types aren't supported in dedicated tenancy, please set --instance-type."))
}
}
fmt.Println(`
___ ___ ___ __ __ ___ __ _
/ ___\ / __ \ / _ \/\ \/\ \ / __ \/\ \/ \
/\ \__//\ \_\ \/\ \/\ \ \ \_/ |/\ \_\ \/> </
\ \____\ \____/\ \_\ \_\ \___/ \ \____//\_/\_\
\/____/\/___/ \/_/\/_/\/__/ \/___/ \//\/_/
`)
fmt.Println("This installer needs AWS credentials to install the Convox platform into")
fmt.Println("your AWS account. These credentials will only be used to communicate")
fmt.Println("between this installer running on your computer and the AWS API.")
fmt.Println("")
fmt.Println("We recommend that you create a new set of credentials exclusively for this")
fmt.Println("install process and then delete them once the installer has completed.")
fmt.Println("")
fmt.Println("To generate a new set of AWS credentials go to:")
fmt.Println("https://docs.convox.com/docs/creating-an-iam-user-and-credentials")
fmt.Println("")
distinctId, err := currentId()
if err != nil {
handleError("install", distinctId, err)
return
}
reader := bufio.NewReader(os.Stdin)
access := os.Getenv("AWS_ACCESS_KEY_ID")
secret := os.Getenv("AWS_SECRET_ACCESS_KEY")
if access == "" || secret == "" {
var err error
fmt.Print("AWS Access Key ID: ")
access, err = reader.ReadString('\n')
if err != nil {
stdcli.Error(err)
}
fmt.Print("AWS Secret Access Key: ")
secret, err = reader.ReadString('\n')
if err != nil {
stdcli.Error(err)
}
fmt.Println("")
}
development := "No"
if c.Bool("development") {
development = "Yes"
}
key := c.String("key")
stackName := c.String("stack-name")
version := c.String("version")
instanceCount := fmt.Sprintf("%d", c.Int("instance-count"))
fmt.Println("Installing Convox...")
access = strings.TrimSpace(access)
secret = strings.TrimSpace(secret)
password := randomString(30)
CloudFormation := cloudformation.New(&aws.Config{
Region: region,
Credentials: credentials.NewStaticCredentials(access, secret, ""),
})
res, err := CloudFormation.CreateStack(&cloudformation.CreateStackInput{
Capabilities: []*string{aws.String("CAPABILITY_IAM")},
Parameters: []*cloudformation.Parameter{
//.........这里部分代码省略.........
开发者ID:ngotnghet,项目名称:cli,代码行数:101,代码来源:install.go
示例8: cmdUninstall
func cmdUninstall(c *cli.Context) {
if !c.Bool("force") {
apps := getApps()
if len(*apps) != 0 {
stdcli.Error(fmt.Errorf("Please delete all apps before uninstalling."))
}
}
fmt.Println(`
___ ___ ___ __ __ ___ __ _
/'___\ / __'\ /' _ '\/\ \/\ \ / __'\/\ \/'\
/\ \__//\ \_\ \/\ \/\ \ \ \_/ |/\ \_\ \/> </
\ \____\ \____/\ \_\ \_\ \___/ \ \____//\_/\_\
\/____/\/___/ \/_/\/_/\/__/ \/___/ \//\/_/
`)
fmt.Println("This uninstaller needs AWS credentials to uninstall the Convox platform from")
fmt.Println("your AWS account. These credentials will only be used to communicate")
fmt.Println("between this uninstaller running on your computer and the AWS API.")
fmt.Println("")
fmt.Println("We recommend that you create a new set of credentials exclusively for this")
fmt.Println("uninstall process and then delete them once the uninstaller has completed.")
fmt.Println("")
fmt.Println("To generate a new set of AWS credentials go to:")
fmt.Println("https://console.aws.amazon.com/iam/home#security_credential")
fmt.Println("")
reader := bufio.NewReader(os.Stdin)
access := os.Getenv("AWS_ACCESS_KEY_ID")
secret := os.Getenv("AWS_SECRET_ACCESS_KEY")
if access == "" || secret == "" {
var err error
fmt.Print("AWS Access Key: ")
access, err = reader.ReadString('\n')
if err != nil {
stdcli.Error(err)
}
fmt.Print("AWS Secret Access Key: ")
secret, err = reader.ReadString('\n')
if err != nil {
stdcli.Error(err)
}
}
stackName := os.Getenv("STACK_NAME")
if stackName == "" {
stackName = "convox"
}
fmt.Println("")
fmt.Println("Uninstalling Convox...")
distinctId := randomString(10)
access = strings.TrimSpace(access)
secret = strings.TrimSpace(secret)
CloudFormation := cloudformation.New(&aws.Config{
Region: c.String("region"),
Credentials: credentials.NewStaticCredentials(access, secret, ""),
})
res, err := CloudFormation.DescribeStackResources(&cloudformation.DescribeStackResourcesInput{
StackName: aws.String(stackName),
})
if err != nil {
handleError("uninstall", distinctId, err)
return
}
stackId := ""
bucket := ""
for _, r := range res.StackResources {
stackId = *r.StackID
if *r.LogicalResourceID == "RegistryBucket" {
bucket = *r.PhysicalResourceID
}
}
_, err = CloudFormation.DeleteStack(&cloudformation.DeleteStackInput{
StackName: aws.String(stackName),
})
if err != nil {
handleError("uninstall", distinctId, err)
//.........这里部分代码省略.........
开发者ID:apeckham,项目名称:cli,代码行数:101,代码来源:install.go
示例9: TestInterface
func TestInterface(t *testing.T) {
assert.Implements(t, (*cloudformationiface.CloudFormationAPI)(nil), cloudformation.New(nil))
}
开发者ID:nguyendangminh,项目名称:cli,代码行数:3,代码来源:interface_test.go
示例10: cmdInstall
func cmdInstall(c *cli.Context) {
fmt.Println(`
___ ___ ___ __ __ ___ __ _
/ ___\ / __ \ / _ \/\ \/\ \ / __ \/\ \/ \
/\ \__//\ \_\ \/\ \/\ \ \ \_/ |/\ \_\ \/> </
\ \____\ \____/\ \_\ \_\ \___/ \ \____//\_/\_\
\/____/\/___/ \/_/\/_/\/__/ \/___/ \//\/_/
`)
fmt.Println("This installer needs AWS credentials to install the Convox platform into")
fmt.Println("your AWS account. These credentials will only be used to communicate")
fmt.Println("between this installer running on your computer and the AWS API.")
fmt.Println("")
fmt.Println("We recommend that you create a new set of credentials exclusively for this")
fmt.Println("install process and then delete them once the installer has completed.")
fmt.Println("")
fmt.Println("To generate a new set of AWS credentials go to:")
fmt.Println("https://console.aws.amazon.com/iam/home?region=us-east-1#security_credential")
fmt.Println("")
distinctId, err := currentId()
if err != nil {
handleError("install", distinctId, err)
return
}
reader := bufio.NewReader(os.Stdin)
access := os.Getenv("AWS_ACCESS_KEY_ID")
secret := os.Getenv("AWS_SECRET_ACCESS_KEY")
if access == "" || secret == "" {
var err error
fmt.Print("AWS Access Key ID: ")
access, err = reader.ReadString('\n')
if err != nil {
stdcli.Error(err)
}
fmt.Print("AWS Secret Access Key: ")
secret, err = reader.ReadString('\n')
if err != nil {
stdcli.Error(err)
}
fmt.Println("")
}
development := os.Getenv("DEVELOPMENT")
if development != "Yes" {
development = "No"
}
key := os.Getenv("KEY")
stackName := os.Getenv("STACK_NAME")
if stackName == "" {
stackName = "convox"
}
version := os.Getenv("VERSION")
if version == "" {
version = "latest"
}
fmt.Println("Installing Convox...")
access = strings.TrimSpace(access)
secret = strings.TrimSpace(secret)
password := randomString(30)
CloudFormation := cloudformation.New(&aws.Config{
Region: "us-east-1",
Credentials: credentials.NewStaticCredentials(access, secret, ""),
})
res, err := CloudFormation.CreateStack(&cloudformation.CreateStackInput{
Capabilities: []*string{aws.String("CAPABILITY_IAM")},
Parameters: []*cloudformation.Parameter{
&cloudformation.Parameter{ParameterKey: aws.String("ClientId"), ParameterValue: aws.String(distinctId)},
&cloudformation.Parameter{ParameterKey: aws.String("Development"), ParameterValue: aws.String(development)},
&cloudformation.Parameter{ParameterKey: aws.String("InstanceCount"), ParameterValue: aws.String("3")},
&cloudformation.Parameter{ParameterKey: aws.String("InstanceType"), ParameterValue: aws.String("t2.small")},
&cloudformation.Parameter{ParameterKey: aws.String("Key"), ParameterValue: aws.String(key)},
&cloudformation.Parameter{ParameterKey: aws.String("Password"), ParameterValue: aws.String(password)},
&cloudformation.Parameter{ParameterKey: aws.String("Version"), ParameterValue: aws.String(version)},
},
StackName: aws.String(stackName),
//.........这里部分代码省略.........
开发者ID:oren,项目名称:cli,代码行数:101,代码来源:install.go
注:本文中的github.com/convox/cli/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/cloudformation.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论