本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/cloudtrail.CloudTrail类的典型用法代码示例。如果您正苦于以下问题:Golang CloudTrail类的具体用法?Golang CloudTrail怎么用?Golang CloudTrail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CloudTrail类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: cloudTrailSetLogging
func cloudTrailSetLogging(conn *cloudtrail.CloudTrail, enabled bool, id string) error {
if enabled {
log.Printf(
"[DEBUG] Starting logging on CloudTrail (%s)",
id)
StartLoggingOpts := &cloudtrail.StartLoggingInput{
Name: aws.String(id),
}
if _, err := conn.StartLogging(StartLoggingOpts); err != nil {
return fmt.Errorf(
"Error starting logging on CloudTrail (%s): %s",
id, err)
}
} else {
log.Printf(
"[DEBUG] Stopping logging on CloudTrail (%s)",
id)
StopLoggingOpts := &cloudtrail.StopLoggingInput{
Name: aws.String(id),
}
if _, err := conn.StopLogging(StopLoggingOpts); err != nil {
return fmt.Errorf(
"Error stopping logging on CloudTrail (%s): %s",
id, err)
}
}
return nil
}
示例2: setTagsCloudtrail
// setTags is a helper to set the tags for a resource. It expects the
// tags field to be named "tags"
func setTagsCloudtrail(conn *cloudtrail.CloudTrail, d *schema.ResourceData) error {
if d.HasChange("tags") {
oraw, nraw := d.GetChange("tags")
o := oraw.(map[string]interface{})
n := nraw.(map[string]interface{})
create, remove := diffTagsCloudtrail(tagsFromMapCloudtrail(o), tagsFromMapCloudtrail(n))
// Set tags
if len(remove) > 0 {
input := cloudtrail.RemoveTagsInput{
ResourceId: aws.String(d.Get("arn").(string)),
TagsList: remove,
}
log.Printf("[DEBUG] Removing CloudTrail tags: %s", input)
_, err := conn.RemoveTags(&input)
if err != nil {
return err
}
}
if len(create) > 0 {
input := cloudtrail.AddTagsInput{
ResourceId: aws.String(d.Get("arn").(string)),
TagsList: create,
}
log.Printf("[DEBUG] Adding CloudTrail tags: %s", input)
_, err := conn.AddTags(&input)
if err != nil {
return err
}
}
}
return nil
}
示例3: cloudTrailGetLoggingStatus
func cloudTrailGetLoggingStatus(conn *cloudtrail.CloudTrail, id *string) (bool, error) {
GetTrailStatusOpts := &cloudtrail.GetTrailStatusInput{
Name: id,
}
resp, err := conn.GetTrailStatus(GetTrailStatusOpts)
if err != nil {
return false, fmt.Errorf("Error retrieving logging status of CloudTrail (%s): %s", *id, err)
}
return *resp.IsLogging, err
}