func resourceAwsCloudTrailUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudtrailconn input := cloudtrail.UpdateTrailInput{ Name: aws.String(d.Id()), } if d.HasChange("s3_bucket_name") { input.S3BucketName = aws.String(d.Get("s3_bucket_name").(string)) } if d.HasChange("s3_key_prefix") { input.S3KeyPrefix = aws.String(d.Get("s3_key_prefix").(string)) } if d.HasChange("cloud_watch_logs_role_arn") { input.CloudWatchLogsRoleArn = aws.String(d.Get("cloud_watch_logs_role_arn").(string)) } if d.HasChange("cloud_watch_logs_group_arn") { input.CloudWatchLogsLogGroupArn = aws.String(d.Get("cloud_watch_logs_group_arn").(string)) } if d.HasChange("include_global_service_events") { input.IncludeGlobalServiceEvents = aws.Bool(d.Get("include_global_service_events").(bool)) } if d.HasChange("is_multi_region_trail") { input.IsMultiRegionTrail = aws.Bool(d.Get("is_multi_region_trail").(bool)) } if d.HasChange("enable_log_file_validation") { input.EnableLogFileValidation = aws.Bool(d.Get("enable_log_file_validation").(bool)) } if d.HasChange("kms_key_id") { input.KmsKeyId = aws.String(d.Get("kms_key_id").(string)) } if d.HasChange("sns_topic_name") { input.SnsTopicName = aws.String(d.Get("sns_topic_name").(string)) } log.Printf("[DEBUG] Updating CloudTrail: %s", input) t, err := conn.UpdateTrail(&input) if err != nil { return err } if d.HasChange("tags") { err := setTagsCloudtrail(conn, d) if err != nil { return err } } if d.HasChange("enable_logging") { log.Printf("[DEBUG] Updating logging on CloudTrail: %s", input) err := cloudTrailSetLogging(conn, d.Get("enable_logging").(bool), *input.Name) if err != nil { return err } } log.Printf("[DEBUG] CloudTrail updated: %s", t) return resourceAwsCloudTrailRead(d, meta) }
func resourceAwsCloudTrailUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudtrailconn input := cloudtrail.UpdateTrailInput{ Name: aws.String(d.Get("name").(string)), } if d.HasChange("s3_bucket_name") { input.S3BucketName = aws.String(d.Get("s3_bucket_name").(string)) } if d.HasChange("s3_key_prefix") { input.S3KeyPrefix = aws.String(d.Get("s3_key_prefix").(string)) } if d.HasChange("cloud_watch_logs_role_arn") { input.CloudWatchLogsRoleArn = aws.String(d.Get("cloud_watch_logs_role_arn").(string)) } if d.HasChange("cloud_watch_logs_group_arn") { input.CloudWatchLogsLogGroupArn = aws.String(d.Get("cloud_watch_logs_group_arn").(string)) } if d.HasChange("include_global_service_events") { input.IncludeGlobalServiceEvents = aws.Bool(d.Get("include_global_service_events").(bool)) } if d.HasChange("sns_topic_name") { input.SnsTopicName = aws.String(d.Get("sns_topic_name").(string)) } log.Printf("[DEBUG] Updating CloudTrail: %s", input) t, err := conn.UpdateTrail(&input) if err != nil { return err } log.Printf("[DEBUG] CloudTrail updated: %s", t) return resourceAwsCloudTrailRead(d, meta) }