本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/cloudtrail.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExampleCloudTrail_RemoveTags
func ExampleCloudTrail_RemoveTags() {
svc := cloudtrail.New(session.New())
params := &cloudtrail.RemoveTagsInput{
ResourceId: aws.String("String"), // Required
TagsList: []*cloudtrail.Tag{
{ // Required
Key: aws.String("String"), // Required
Value: aws.String("String"),
},
// More values...
},
}
resp, err := svc.RemoveTags(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)
}
示例2: ExampleCloudTrail_ListPublicKeys
func ExampleCloudTrail_ListPublicKeys() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := cloudtrail.New(sess)
params := &cloudtrail.ListPublicKeysInput{
EndTime: aws.Time(time.Now()),
NextToken: aws.String("String"),
StartTime: aws.Time(time.Now()),
}
resp, err := svc.ListPublicKeys(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)
}
示例3: ExampleCloudTrail_LookupEvents
func ExampleCloudTrail_LookupEvents() {
svc := cloudtrail.New(nil)
params := &cloudtrail.LookupEventsInput{
EndTime: aws.Time(time.Now()),
LookupAttributes: []*cloudtrail.LookupAttribute{
{ // Required
AttributeKey: aws.String("LookupAttributeKey"), // Required
AttributeValue: aws.String("String"), // Required
},
// More values...
},
MaxResults: aws.Int64(1),
NextToken: aws.String("NextToken"),
StartTime: aws.Time(time.Now()),
}
resp, err := svc.LookupEvents(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: ExampleCloudTrail_ListTags
func ExampleCloudTrail_ListTags() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := cloudtrail.New(sess)
params := &cloudtrail.ListTagsInput{
ResourceIdList: []*string{ // Required
aws.String("String"), // Required
// More values...
},
NextToken: aws.String("String"),
}
resp, err := svc.ListTags(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: ExampleCloudTrail_DescribeTrails
func ExampleCloudTrail_DescribeTrails() {
svc := cloudtrail.New(nil)
params := &cloudtrail.DescribeTrailsInput{
TrailNameList: []*string{
aws.String("String"), // Required
// More values...
},
}
resp, err := svc.DescribeTrails(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))
}
示例6: ExampleCloudTrail_DescribeTrails
func ExampleCloudTrail_DescribeTrails() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := cloudtrail.New(sess)
params := &cloudtrail.DescribeTrailsInput{
IncludeShadowTrails: aws.Bool(true),
TrailNameList: []*string{
aws.String("String"), // Required
// More values...
},
}
resp, err := svc.DescribeTrails(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)
}
示例7: ExampleCloudTrail_UpdateTrail
func ExampleCloudTrail_UpdateTrail() {
svc := cloudtrail.New(nil)
params := &cloudtrail.UpdateTrailInput{
Name: aws.String("String"), // Required
CloudWatchLogsLogGroupARN: aws.String("String"),
CloudWatchLogsRoleARN: aws.String("String"),
IncludeGlobalServiceEvents: aws.Boolean(true),
S3BucketName: aws.String("String"),
S3KeyPrefix: aws.String("String"),
SNSTopicName: aws.String("String"),
}
resp, err := svc.UpdateTrail(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))
}
示例8: ExampleCloudTrail_CreateTrail
func ExampleCloudTrail_CreateTrail() {
svc := cloudtrail.New(session.New())
params := &cloudtrail.CreateTrailInput{
Name: aws.String("String"), // Required
S3BucketName: aws.String("String"), // Required
CloudWatchLogsLogGroupArn: aws.String("String"),
CloudWatchLogsRoleArn: aws.String("String"),
EnableLogFileValidation: aws.Bool(true),
IncludeGlobalServiceEvents: aws.Bool(true),
KmsKeyId: aws.String("String"),
S3KeyPrefix: aws.String("String"),
SnsTopicName: aws.String("String"),
}
resp, err := svc.CreateTrail(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)
}
示例9: ExampleCloudTrail_GetTrailStatus
func ExampleCloudTrail_GetTrailStatus() {
svc := cloudtrail.New(nil)
params := &cloudtrail.GetTrailStatusInput{
Name: aws.String("String"), // Required
}
resp, err := svc.GetTrailStatus(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: ExampleCloudTrail_PutEventSelectors
func ExampleCloudTrail_PutEventSelectors() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := cloudtrail.New(sess)
params := &cloudtrail.PutEventSelectorsInput{
EventSelectors: []*cloudtrail.EventSelector{
{ // Required
DataResources: []*cloudtrail.DataResource{
{ // Required
Type: aws.String("String"),
Values: []*string{
aws.String("String"), // Required
// More values...
},
},
// More values...
},
IncludeManagementEvents: aws.Bool(true),
ReadWriteType: aws.String("ReadWriteType"),
},
// More values...
},
TrailName: aws.String("String"),
}
resp, err := svc.PutEventSelectors(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)
}
示例11: ExampleCloudTrail_DescribeTrails
func ExampleCloudTrail_DescribeTrails() {
svc := cloudtrail.New(nil)
params := &cloudtrail.DescribeTrailsInput{
TrailNameList: []*string{
aws.String("String"), // Required
// More values...
},
}
resp, err := svc.DescribeTrails(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: ExampleCloudTrail_LookupEvents
func ExampleCloudTrail_LookupEvents() {
svc := cloudtrail.New(nil)
params := &cloudtrail.LookupEventsInput{
EndTime: aws.Time(time.Now()),
LookupAttributes: []*cloudtrail.LookupAttribute{
{ // Required
AttributeKey: aws.String("LookupAttributeKey"), // Required
AttributeValue: aws.String("String"), // Required
},
// More values...
},
MaxResults: aws.Long(1),
NextToken: aws.String("NextToken"),
StartTime: aws.Time(time.Now()),
}
resp, err := svc.LookupEvents(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))
}
示例13: ExampleCloudTrail_DeleteTrail
func ExampleCloudTrail_DeleteTrail() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := cloudtrail.New(sess)
params := &cloudtrail.DeleteTrailInput{
Name: aws.String("String"), // Required
}
resp, err := svc.DeleteTrail(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: Client
// Client configures and returns a fully initialized AWSClient
func (c *Config) Client() (interface{}, error) {
// Get the auth and region. This can fail if keys/regions were not
// specified and we're attempting to use the environment.
log.Println("[INFO] Building AWS region structure")
err := c.ValidateRegion()
if err != nil {
return nil, err
}
var client AWSClient
// store AWS region in client struct, for region specific operations such as
// bucket storage in S3
client.region = c.Region
log.Println("[INFO] Building AWS auth structure")
creds, err := GetCredentials(c)
if err != nil {
return nil, err
}
// Call Get to check for credential provider. If nothing found, we'll get an
// error, and we can present it nicely to the user
cp, err := creds.Get()
if err != nil {
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NoCredentialProviders" {
return nil, errors.New(`No valid credential sources found for AWS Provider.
Please see https://terraform.io/docs/providers/aws/index.html for more information on
providing credentials for the AWS Provider`)
}
return nil, fmt.Errorf("Error loading credentials for AWS Provider: %s", err)
}
log.Printf("[INFO] AWS Auth provider used: %q", cp.ProviderName)
awsConfig := &aws.Config{
Credentials: creds,
Region: aws.String(c.Region),
MaxRetries: aws.Int(c.MaxRetries),
HTTPClient: cleanhttp.DefaultClient(),
S3ForcePathStyle: aws.Bool(c.S3ForcePathStyle),
}
if logging.IsDebugOrHigher() {
awsConfig.LogLevel = aws.LogLevel(aws.LogDebugWithHTTPBody)
awsConfig.Logger = awsLogger{}
}
if c.Insecure {
transport := awsConfig.HTTPClient.Transport.(*http.Transport)
transport.TLSClientConfig = &tls.Config{
InsecureSkipVerify: true,
}
}
// Set up base session
sess, err := session.NewSession(awsConfig)
if err != nil {
return nil, errwrap.Wrapf("Error creating AWS session: {{err}}", err)
}
// Removes the SDK Version handler, so we only have the provider User-Agent
// Ex: "User-Agent: APN/1.0 HashiCorp/1.0 Terraform/0.7.9-dev"
sess.Handlers.Build.Remove(request.NamedHandler{Name: "core.SDKVersionUserAgentHandler"})
sess.Handlers.Build.PushFrontNamed(addTerraformVersionToUserAgent)
if extraDebug := os.Getenv("TERRAFORM_AWS_AUTHFAILURE_DEBUG"); extraDebug != "" {
sess.Handlers.UnmarshalError.PushFrontNamed(debugAuthFailure)
}
// Some services exist only in us-east-1, e.g. because they manage
// resources that can span across multiple regions, or because
// signature format v4 requires region to be us-east-1 for global
// endpoints:
// http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html
usEast1Sess := sess.Copy(&aws.Config{Region: aws.String("us-east-1")})
// Some services have user-configurable endpoints
awsEc2Sess := sess.Copy(&aws.Config{Endpoint: aws.String(c.Ec2Endpoint)})
awsElbSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.ElbEndpoint)})
awsIamSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.IamEndpoint)})
awsS3Sess := sess.Copy(&aws.Config{Endpoint: aws.String(c.S3Endpoint)})
dynamoSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.DynamoDBEndpoint)})
kinesisSess := sess.Copy(&aws.Config{Endpoint: aws.String(c.KinesisEndpoint)})
// These two services need to be set up early so we can check on AccountID
client.iamconn = iam.New(awsIamSess)
client.stsconn = sts.New(sess)
if !c.SkipCredsValidation {
err = c.ValidateCredentials(client.stsconn)
if err != nil {
return nil, err
}
}
if !c.SkipRequestingAccountId {
partition, accountId, err := GetAccountInfo(client.iamconn, client.stsconn, cp.ProviderName)
if err == nil {
client.partition = partition
//.........这里部分代码省略.........
示例15: TestInterface
func TestInterface(t *testing.T) {
assert.Implements(t, (*cloudtrailiface.CloudTrailAPI)(nil), cloudtrail.New(nil))
}