1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package cloudtrail
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/smithy-go/middleware"
10	smithyhttp "github.com/aws/smithy-go/transport/http"
11)
12
13// Updates the settings that specify delivery of log files. Changes to a trail do
14// not require stopping the CloudTrail service. Use this action to designate an
15// existing bucket for log delivery. If the existing bucket has previously been a
16// target for CloudTrail log files, an IAM policy exists for the bucket.
17// UpdateTrail must be called from the region in which the trail was created;
18// otherwise, an InvalidHomeRegionException is thrown.
19func (c *Client) UpdateTrail(ctx context.Context, params *UpdateTrailInput, optFns ...func(*Options)) (*UpdateTrailOutput, error) {
20	if params == nil {
21		params = &UpdateTrailInput{}
22	}
23
24	result, metadata, err := c.invokeOperation(ctx, "UpdateTrail", params, optFns, addOperationUpdateTrailMiddlewares)
25	if err != nil {
26		return nil, err
27	}
28
29	out := result.(*UpdateTrailOutput)
30	out.ResultMetadata = metadata
31	return out, nil
32}
33
34// Specifies settings to update for the trail.
35type UpdateTrailInput struct {
36
37	// Specifies the name of the trail or trail ARN. If Name is a trail name, the
38	// string must meet the following requirements:
39	//
40	// * Contain only ASCII letters (a-z,
41	// A-Z), numbers (0-9), periods (.), underscores (_), or dashes (-)
42	//
43	// * Start with a
44	// letter or number, and end with a letter or number
45	//
46	// * Be between 3 and 128
47	// characters
48	//
49	// * Have no adjacent periods, underscores or dashes. Names like
50	// my-_namespace and my--namespace are invalid.
51	//
52	// * Not be in IP address format (for
53	// example, 192.168.5.4)
54	//
55	// If Name is a trail ARN, it must be in the format:
56	// arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
57	//
58	// This member is required.
59	Name *string
60
61	// Specifies a log group name using an Amazon Resource Name (ARN), a unique
62	// identifier that represents the log group to which CloudTrail logs will be
63	// delivered. Not required unless you specify CloudWatchLogsRoleArn.
64	CloudWatchLogsLogGroupArn *string
65
66	// Specifies the role for the CloudWatch Logs endpoint to assume to write to a
67	// user's log group.
68	CloudWatchLogsRoleArn *string
69
70	// Specifies whether log file validation is enabled. The default is false. When you
71	// disable log file integrity validation, the chain of digest files is broken after
72	// one hour. CloudTrail will not create digest files for log files that were
73	// delivered during a period in which log file integrity validation was disabled.
74	// For example, if you enable log file integrity validation at noon on January 1,
75	// disable it at noon on January 2, and re-enable it at noon on January 10, digest
76	// files will not be created for the log files delivered from noon on January 2 to
77	// noon on January 10. The same applies whenever you stop CloudTrail logging or
78	// delete a trail.
79	EnableLogFileValidation *bool
80
81	// Specifies whether the trail is publishing events from global services such as
82	// IAM to the log files.
83	IncludeGlobalServiceEvents *bool
84
85	// Specifies whether the trail applies only to the current region or to all
86	// regions. The default is false. If the trail exists only in the current region
87	// and this value is set to true, shadow trails (replications of the trail) will be
88	// created in the other regions. If the trail exists in all regions and this value
89	// is set to false, the trail will remain in the region where it was created, and
90	// its shadow trails in other regions will be deleted. As a best practice, consider
91	// using trails that log events in all regions.
92	IsMultiRegionTrail *bool
93
94	// Specifies whether the trail is applied to all accounts in an organization in AWS
95	// Organizations, or only for the current AWS account. The default is false, and
96	// cannot be true unless the call is made on behalf of an AWS account that is the
97	// master account for an organization in AWS Organizations. If the trail is not an
98	// organization trail and this is set to true, the trail will be created in all AWS
99	// accounts that belong to the organization. If the trail is an organization trail
100	// and this is set to false, the trail will remain in the current AWS account but
101	// be deleted from all member accounts in the organization.
102	IsOrganizationTrail *bool
103
104	// Specifies the KMS key ID to use to encrypt the logs delivered by CloudTrail. The
105	// value can be an alias name prefixed by "alias/", a fully specified ARN to an
106	// alias, a fully specified ARN to a key, or a globally unique identifier.
107	// Examples:
108	//
109	// * alias/MyAliasName
110	//
111	// *
112	// arn:aws:kms:us-east-2:123456789012:alias/MyAliasName
113	//
114	// *
115	// arn:aws:kms:us-east-2:123456789012:key/12345678-1234-1234-1234-123456789012
116	//
117	// *
118	// 12345678-1234-1234-1234-123456789012
119	KmsKeyId *string
120
121	// Specifies the name of the Amazon S3 bucket designated for publishing log files.
122	// See Amazon S3 Bucket Naming Requirements
123	// (https://docs.aws.amazon.com/awscloudtrail/latest/userguide/create_trail_naming_policy.html).
124	S3BucketName *string
125
126	// Specifies the Amazon S3 key prefix that comes after the name of the bucket you
127	// have designated for log file delivery. For more information, see Finding Your
128	// CloudTrail Log Files
129	// (https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-find-log-files.html).
130	// The maximum length is 200 characters.
131	S3KeyPrefix *string
132
133	// Specifies the name of the Amazon SNS topic defined for notification of log file
134	// delivery. The maximum length is 256 characters.
135	SnsTopicName *string
136}
137
138// Returns the objects or data listed below if successful. Otherwise, returns an
139// error.
140type UpdateTrailOutput struct {
141
142	// Specifies the Amazon Resource Name (ARN) of the log group to which CloudTrail
143	// logs will be delivered.
144	CloudWatchLogsLogGroupArn *string
145
146	// Specifies the role for the CloudWatch Logs endpoint to assume to write to a
147	// user's log group.
148	CloudWatchLogsRoleArn *string
149
150	// Specifies whether the trail is publishing events from global services such as
151	// IAM to the log files.
152	IncludeGlobalServiceEvents *bool
153
154	// Specifies whether the trail exists in one region or in all regions.
155	IsMultiRegionTrail *bool
156
157	// Specifies whether the trail is an organization trail.
158	IsOrganizationTrail *bool
159
160	// Specifies the KMS key ID that encrypts the logs delivered by CloudTrail. The
161	// value is a fully specified ARN to a KMS key in the format:
162	// arn:aws:kms:us-east-2:123456789012:key/12345678-1234-1234-1234-123456789012
163	KmsKeyId *string
164
165	// Specifies whether log file integrity validation is enabled.
166	LogFileValidationEnabled *bool
167
168	// Specifies the name of the trail.
169	Name *string
170
171	// Specifies the name of the Amazon S3 bucket designated for publishing log files.
172	S3BucketName *string
173
174	// Specifies the Amazon S3 key prefix that comes after the name of the bucket you
175	// have designated for log file delivery. For more information, see Finding Your
176	// CloudTrail Log Files
177	// (https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-find-log-files.html).
178	S3KeyPrefix *string
179
180	// Specifies the ARN of the Amazon SNS topic that CloudTrail uses to send
181	// notifications when log files are delivered. The format of a topic ARN is:
182	// arn:aws:sns:us-east-2:123456789012:MyTopic
183	SnsTopicARN *string
184
185	// This field is no longer in use. Use SnsTopicARN.
186	//
187	// Deprecated: This member has been deprecated.
188	SnsTopicName *string
189
190	// Specifies the ARN of the trail that was updated. The format of a trail ARN is:
191	// arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail
192	TrailARN *string
193
194	// Metadata pertaining to the operation's result.
195	ResultMetadata middleware.Metadata
196}
197
198func addOperationUpdateTrailMiddlewares(stack *middleware.Stack, options Options) (err error) {
199	err = stack.Serialize.Add(&awsAwsjson11_serializeOpUpdateTrail{}, middleware.After)
200	if err != nil {
201		return err
202	}
203	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpUpdateTrail{}, middleware.After)
204	if err != nil {
205		return err
206	}
207	if err = addSetLoggerMiddleware(stack, options); err != nil {
208		return err
209	}
210	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
211		return err
212	}
213	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
214		return err
215	}
216	if err = addResolveEndpointMiddleware(stack, options); err != nil {
217		return err
218	}
219	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
220		return err
221	}
222	if err = addRetryMiddlewares(stack, options); err != nil {
223		return err
224	}
225	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
226		return err
227	}
228	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
229		return err
230	}
231	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
232		return err
233	}
234	if err = addClientUserAgent(stack); err != nil {
235		return err
236	}
237	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
238		return err
239	}
240	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
241		return err
242	}
243	if err = addOpUpdateTrailValidationMiddleware(stack); err != nil {
244		return err
245	}
246	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUpdateTrail(options.Region), middleware.Before); err != nil {
247		return err
248	}
249	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
250		return err
251	}
252	if err = addResponseErrorMiddleware(stack); err != nil {
253		return err
254	}
255	if err = addRequestResponseLogging(stack, options); err != nil {
256		return err
257	}
258	return nil
259}
260
261func newServiceMetadataMiddleware_opUpdateTrail(region string) *awsmiddleware.RegisterServiceMetadata {
262	return &awsmiddleware.RegisterServiceMetadata{
263		Region:        region,
264		ServiceID:     ServiceID,
265		SigningName:   "cloudtrail",
266		OperationName: "UpdateTrail",
267	}
268}
269