api_op_PutDataProtectionPolicy.go 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. // Code generated by smithy-go-codegen DO NOT EDIT.
  2. package cloudwatchlogs
  3. import (
  4. "context"
  5. "fmt"
  6. awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
  7. "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
  8. "github.com/aws/smithy-go/middleware"
  9. smithyhttp "github.com/aws/smithy-go/transport/http"
  10. )
  11. // Creates a data protection policy for the specified log group. A data protection
  12. // policy can help safeguard sensitive data that's ingested by the log group by
  13. // auditing and masking the sensitive log data. Sensitive data is detected and
  14. // masked when it is ingested into the log group. When you set a data protection
  15. // policy, log events ingested into the log group before that time are not masked.
  16. // By default, when a user views a log event that includes masked data, the
  17. // sensitive data is replaced by asterisks. A user who has the logs:Unmask
  18. // permission can use a GetLogEvents (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_GetLogEvents.html)
  19. // or FilterLogEvents (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_FilterLogEvents.html)
  20. // operation with the unmask parameter set to true to view the unmasked log
  21. // events. Users with the logs:Unmask can also view unmasked data in the
  22. // CloudWatch Logs console by running a CloudWatch Logs Insights query with the
  23. // unmask query command. For more information, including a list of types of data
  24. // that can be audited and masked, see Protect sensitive log data with masking (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/mask-sensitive-log-data.html)
  25. // . The PutDataProtectionPolicy operation applies to only the specified log
  26. // group. You can also use PutAccountPolicy (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutAccountPolicy.html)
  27. // to create an account-level data protection policy that applies to all log groups
  28. // in the account, including both existing log groups and log groups that are
  29. // created level. If a log group has its own data protection policy and the account
  30. // also has an account-level data protection policy, then the two policies are
  31. // cumulative. Any sensitive term specified in either policy is masked.
  32. func (c *Client) PutDataProtectionPolicy(ctx context.Context, params *PutDataProtectionPolicyInput, optFns ...func(*Options)) (*PutDataProtectionPolicyOutput, error) {
  33. if params == nil {
  34. params = &PutDataProtectionPolicyInput{}
  35. }
  36. result, metadata, err := c.invokeOperation(ctx, "PutDataProtectionPolicy", params, optFns, c.addOperationPutDataProtectionPolicyMiddlewares)
  37. if err != nil {
  38. return nil, err
  39. }
  40. out := result.(*PutDataProtectionPolicyOutput)
  41. out.ResultMetadata = metadata
  42. return out, nil
  43. }
  44. type PutDataProtectionPolicyInput struct {
  45. // Specify either the log group name or log group ARN.
  46. //
  47. // This member is required.
  48. LogGroupIdentifier *string
  49. // Specify the data protection policy, in JSON. This policy must include two JSON
  50. // blocks:
  51. // - The first block must include both a DataIdentifer array and an Operation
  52. // property with an Audit action. The DataIdentifer array lists the types of
  53. // sensitive data that you want to mask. For more information about the available
  54. // options, see Types of data that you can mask (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/mask-sensitive-log-data-types.html)
  55. // . The Operation property with an Audit action is required to find the
  56. // sensitive data terms. This Audit action must contain a FindingsDestination
  57. // object. You can optionally use that FindingsDestination object to list one or
  58. // more destinations to send audit findings to. If you specify destinations such as
  59. // log groups, Kinesis Data Firehose streams, and S3 buckets, they must already
  60. // exist.
  61. // - The second block must include both a DataIdentifer array and an Operation
  62. // property with an Deidentify action. The DataIdentifer array must exactly match
  63. // the DataIdentifer array in the first block of the policy. The Operation
  64. // property with the Deidentify action is what actually masks the data, and it
  65. // must contain the "MaskConfig": {} object. The "MaskConfig": {} object must be
  66. // empty.
  67. // For an example data protection policy, see the Examples section on this page.
  68. // The contents of the two DataIdentifer arrays must match exactly. In addition to
  69. // the two JSON blocks, the policyDocument can also include Name , Description ,
  70. // and Version fields. The Name is used as a dimension when CloudWatch Logs
  71. // reports audit findings metrics to CloudWatch. The JSON specified in
  72. // policyDocument can be up to 30,720 characters.
  73. //
  74. // This member is required.
  75. PolicyDocument *string
  76. noSmithyDocumentSerde
  77. }
  78. type PutDataProtectionPolicyOutput struct {
  79. // The date and time that this policy was most recently updated.
  80. LastUpdatedTime *int64
  81. // The log group name or ARN that you specified in your request.
  82. LogGroupIdentifier *string
  83. // The data protection policy used for this log group.
  84. PolicyDocument *string
  85. // Metadata pertaining to the operation's result.
  86. ResultMetadata middleware.Metadata
  87. noSmithyDocumentSerde
  88. }
  89. func (c *Client) addOperationPutDataProtectionPolicyMiddlewares(stack *middleware.Stack, options Options) (err error) {
  90. if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  91. return err
  92. }
  93. err = stack.Serialize.Add(&awsAwsjson11_serializeOpPutDataProtectionPolicy{}, middleware.After)
  94. if err != nil {
  95. return err
  96. }
  97. err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpPutDataProtectionPolicy{}, middleware.After)
  98. if err != nil {
  99. return err
  100. }
  101. if err := addProtocolFinalizerMiddlewares(stack, options, "PutDataProtectionPolicy"); err != nil {
  102. return fmt.Errorf("add protocol finalizers: %v", err)
  103. }
  104. if err = addlegacyEndpointContextSetter(stack, options); err != nil {
  105. return err
  106. }
  107. if err = addSetLoggerMiddleware(stack, options); err != nil {
  108. return err
  109. }
  110. if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
  111. return err
  112. }
  113. if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
  114. return err
  115. }
  116. if err = addResolveEndpointMiddleware(stack, options); err != nil {
  117. return err
  118. }
  119. if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
  120. return err
  121. }
  122. if err = addRetryMiddlewares(stack, options); err != nil {
  123. return err
  124. }
  125. if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
  126. return err
  127. }
  128. if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
  129. return err
  130. }
  131. if err = addClientUserAgent(stack, options); err != nil {
  132. return err
  133. }
  134. if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
  135. return err
  136. }
  137. if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
  138. return err
  139. }
  140. if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
  141. return err
  142. }
  143. if err = addOpPutDataProtectionPolicyValidationMiddleware(stack); err != nil {
  144. return err
  145. }
  146. if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutDataProtectionPolicy(options.Region), middleware.Before); err != nil {
  147. return err
  148. }
  149. if err = awsmiddleware.AddRecursionDetection(stack); err != nil {
  150. return err
  151. }
  152. if err = addRequestIDRetrieverMiddleware(stack); err != nil {
  153. return err
  154. }
  155. if err = addResponseErrorMiddleware(stack); err != nil {
  156. return err
  157. }
  158. if err = addRequestResponseLogging(stack, options); err != nil {
  159. return err
  160. }
  161. if err = addDisableHTTPSMiddleware(stack, options); err != nil {
  162. return err
  163. }
  164. return nil
  165. }
  166. func newServiceMetadataMiddleware_opPutDataProtectionPolicy(region string) *awsmiddleware.RegisterServiceMetadata {
  167. return &awsmiddleware.RegisterServiceMetadata{
  168. Region: region,
  169. ServiceID: ServiceID,
  170. OperationName: "PutDataProtectionPolicy",
  171. }
  172. }