Class: AWSCDK::CloudTrail::Trail
- Inherits:
-
Resource
- Object
- Resource
- AWSCDK::CloudTrail::Trail
- Defined in:
- cloud_trail/trail.rb
Overview
Cloud trail allows you to log events that happen in your AWS account For example:.
import { CloudTrail } from 'aws-cdk-lib/aws-cloudtrail'
const cloudTrail = new CloudTrail(this, 'MyTrail');
Class Method Summary collapse
- .jsii_overridable_methods ⇒ Object
-
.on_event(scope, id, options = nil) ⇒ AWSCDK::Events::Rule
Create an event rule for when an event is recorded by any Trail in the account.
-
.PROPERTY_INJECTION_ID ⇒ String
Uniquely identifies this class.
Instance Method Summary collapse
-
#add_event_selector(data_resource_type, data_resource_values, options = nil) ⇒ void
When an event occurs in your account, CloudTrail evaluates whether the event matches the settings for your trails.
-
#add_lambda_event_selector(handlers, options = nil) ⇒ void
When an event occurs in your account, CloudTrail evaluates whether the event matches the settings for your trails.
-
#add_s3_event_selector(s3_selector, options = nil) ⇒ void
When an event occurs in your account, CloudTrail evaluates whether the event matches the settings for your trails.
-
#apply_cross_stack_reference_strength(strength) ⇒ void
Override the cross-stack reference strength for this resource.
-
#apply_removal_policy(policy) ⇒ void
Apply the given removal policy to this resource.
-
#env ⇒ AWSCDK::Interfaces::ResourceEnvironment
The environment this resource belongs to.
- #generate_physical_name ⇒ String
-
#get_resource_arn_attribute(arn_attr, arn_components) ⇒ String
Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g.
bucket.bucketArn). -
#get_resource_name_attribute(name_attr) ⇒ String
Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g.
bucket.bucketName). -
#initialize(scope, id, props = nil) ⇒ Trail
constructor
A new instance of Trail.
-
#log_all_lambda_data_events(options = nil) ⇒ void
Log all Lambda data events for all lambda functions the account.
-
#log_all_s3_data_events(options = nil) ⇒ void
Log all S3 data events for all objects for all buckets in the account.
-
#log_group ⇒ AWSCDK::Logs::ILogGroup?
The CloudWatch log group to which CloudTrail events are sent.
-
#node ⇒ Constructs::Node
The tree node.
-
#physical_name ⇒ String
Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.
-
#stack ⇒ AWSCDK::Stack
The stack in which this resource is defined.
-
#to_string ⇒ String
Returns a string representation of this construct.
-
#trail_arn ⇒ String
ARN of the CloudTrail trail i.e.
-
#trail_sns_topic_arn ⇒ String
ARN of the Amazon SNS topic that's associated with the CloudTrail trail, i.e.
-
#with(*mixins) ⇒ Constructs::IConstruct
Applies one or more mixins to this construct.
Constructor Details
#initialize(scope, id, props = nil) ⇒ Trail
Returns a new instance of Trail.
15 16 17 18 19 20 21 |
# File 'cloud_trail/trail.rb', line 15 def initialize(scope, id, props = nil) props = props.is_a?(Hash) ? ::AWSCDK::CloudTrail::TrailProps.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope") Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id") Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR0cmFpbC5UcmFpbFByb3BzIn0=")), "props") unless props.nil? Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props) end |
Class Method Details
.jsii_overridable_methods ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'cloud_trail/trail.rb', line 23 def self.jsii_overridable_methods { :node => { kind: :property, name: "node", is_optional: false }, :env => { kind: :property, name: "env", is_optional: false }, :physical_name => { kind: :property, name: "physicalName", is_optional: false }, :stack => { kind: :property, name: "stack", is_optional: false }, :trail_arn => { kind: :property, name: "trailArn", is_optional: false }, :trail_sns_topic_arn => { kind: :property, name: "trailSnsTopicArn", is_optional: false }, :log_group => { kind: :property, name: "logGroup", is_optional: true }, :to_string => { kind: :method, name: "toString", is_optional: false }, :with => { kind: :method, name: "with", is_optional: false }, :apply_cross_stack_reference_strength => { kind: :method, name: "applyCrossStackReferenceStrength", is_optional: false }, :apply_removal_policy => { kind: :method, name: "applyRemovalPolicy", is_optional: false }, :generate_physical_name => { kind: :method, name: "generatePhysicalName", is_optional: false }, :get_resource_arn_attribute => { kind: :method, name: "getResourceArnAttribute", is_optional: false }, :get_resource_name_attribute => { kind: :method, name: "getResourceNameAttribute", is_optional: false }, :add_event_selector => { kind: :method, name: "addEventSelector", is_optional: false }, :add_lambda_event_selector => { kind: :method, name: "addLambdaEventSelector", is_optional: false }, :add_s3_event_selector => { kind: :method, name: "addS3EventSelector", is_optional: false }, :log_all_lambda_data_events => { kind: :method, name: "logAllLambdaDataEvents", is_optional: false }, :log_all_s3_data_events => { kind: :method, name: "logAllS3DataEvents", is_optional: false }, } end |
.on_event(scope, id, options = nil) ⇒ AWSCDK::Events::Rule
Create an event rule for when an event is recorded by any Trail in the account.
Note that the event doesn't necessarily have to come from this Trail, it can be captured from any one.
Be sure to filter the event further down using an event pattern.
58 59 60 61 62 63 64 |
# File 'cloud_trail/trail.rb', line 58 def self.on_event(scope, id, = nil) Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope") Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id") = .is_a?(Hash) ? ::AWSCDK::Events::OnEventOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZXZlbnRzLk9uRXZlbnRPcHRpb25zIn0=")), "options") unless .nil? Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_cloudtrail.Trail", "onEvent", [scope, id, ]) end |
.PROPERTY_INJECTION_ID ⇒ String
Uniquely identifies this class.
112 113 114 |
# File 'cloud_trail/trail.rb', line 112 def self.PROPERTY_INJECTION_ID() Jsii::Kernel.instance.get_static("aws-cdk-lib.aws_cloudtrail.Trail", "PROPERTY_INJECTION_ID") end |
Instance Method Details
#add_event_selector(data_resource_type, data_resource_values, options = nil) ⇒ void
This method returns an undefined value.
When an event occurs in your account, CloudTrail evaluates whether the event matches the settings for your trails.
Only events that match your trail settings are delivered to your Amazon S3 bucket and Amazon CloudWatch Logs log group.
This method adds an Event Selector for filtering events that match either S3 or Lambda function operations.
Data events: These events provide insight into the resource operations performed on or within a resource. These are also known as data plane operations.
242 243 244 245 246 247 248 |
# File 'cloud_trail/trail.rb', line 242 def add_event_selector(data_resource_type, data_resource_values, = nil) Jsii::Type.check_type(data_resource_type, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR0cmFpbC5EYXRhUmVzb3VyY2VUeXBlIn0=")), "dataResourceType") Jsii::Type.check_type(data_resource_values, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "dataResourceValues") = .is_a?(Hash) ? ::AWSCDK::CloudTrail::AddEventSelectorOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR0cmFpbC5BZGRFdmVudFNlbGVjdG9yT3B0aW9ucyJ9")), "options") unless .nil? jsii_call_method("addEventSelector", [data_resource_type, data_resource_values, ]) end |
#add_lambda_event_selector(handlers, options = nil) ⇒ void
This method returns an undefined value.
When an event occurs in your account, CloudTrail evaluates whether the event matches the settings for your trails.
Only events that match your trail settings are delivered to your Amazon S3 bucket and Amazon CloudWatch Logs log group.
This method adds a Lambda Data Event Selector for filtering events that match Lambda function operations.
Data events: These events provide insight into the resource operations performed on or within a resource. These are also known as data plane operations.
262 263 264 265 266 267 |
# File 'cloud_trail/trail.rb', line 262 def add_lambda_event_selector(handlers, = nil) Jsii::Type.check_type(handlers, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19sYW1iZGEuSUZ1bmN0aW9uIn0sImtpbmQiOiJhcnJheSJ9fQ==")), "handlers") = .is_a?(Hash) ? ::AWSCDK::CloudTrail::AddEventSelectorOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR0cmFpbC5BZGRFdmVudFNlbGVjdG9yT3B0aW9ucyJ9")), "options") unless .nil? jsii_call_method("addLambdaEventSelector", [handlers, ]) end |
#add_s3_event_selector(s3_selector, options = nil) ⇒ void
This method returns an undefined value.
When an event occurs in your account, CloudTrail evaluates whether the event matches the settings for your trails.
Only events that match your trail settings are delivered to your Amazon S3 bucket and Amazon CloudWatch Logs log group.
This method adds an S3 Data Event Selector for filtering events that match S3 operations.
Data events: These events provide insight into the resource operations performed on or within a resource. These are also known as data plane operations.
281 282 283 284 285 286 287 |
# File 'cloud_trail/trail.rb', line 281 def add_s3_event_selector(s3_selector, = nil) s3_selector = s3_selector.is_a?(Array) ? s3_selector.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::CloudTrail::S3EventSelector.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : s3_selector Jsii::Type.check_type(s3_selector, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19jbG91ZHRyYWlsLlMzRXZlbnRTZWxlY3RvciJ9LCJraW5kIjoiYXJyYXkifX0=")), "s3Selector") = .is_a?(Hash) ? ::AWSCDK::CloudTrail::AddEventSelectorOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR0cmFpbC5BZGRFdmVudFNlbGVjdG9yT3B0aW9ucyJ9")), "options") unless .nil? jsii_call_method("addS3EventSelector", [s3_selector, ]) end |
#apply_cross_stack_reference_strength(strength) ⇒ void
This method returns an undefined value.
Override the cross-stack reference strength for this resource.
When set, any cross-stack reference to this resource will use the specified
mechanism instead of the global default determined by the
@aws-cdk/core:defaultCrossStackReferences context key. This is useful for
selectively weakening specific references to avoid the "deadly embrace" problem
without changing the app-wide default.
172 173 174 175 |
# File 'cloud_trail/trail.rb', line 172 def apply_cross_stack_reference_strength(strength) Jsii::Type.check_type(strength, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZWZlcmVuY2VTdHJlbmd0aCJ9")), "strength") jsii_call_method("applyCrossStackReferenceStrength", [strength]) end |
#apply_removal_policy(policy) ⇒ void
This method returns an undefined value.
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN).
189 190 191 192 |
# File 'cloud_trail/trail.rb', line 189 def apply_removal_policy(policy) Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZW1vdmFsUG9saWN5In0=")), "policy") jsii_call_method("applyRemovalPolicy", [policy]) end |
#env ⇒ AWSCDK::Interfaces::ResourceEnvironment
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
84 85 86 |
# File 'cloud_trail/trail.rb', line 84 def env() jsii_get_property("env") end |
#generate_physical_name ⇒ String
195 196 197 |
# File 'cloud_trail/trail.rb', line 195 def generate_physical_name() jsii_call_method("generatePhysicalName", []) end |
#get_resource_arn_attribute(arn_attr, arn_components) ⇒ String
Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. bucket.bucketArn).
Normally, this token will resolve to arn_attr, but if the resource is
referenced across environments, arn_components will be used to synthesize
a concrete ARN with the resource's physical name. Make sure to reference
this.physicalName in arn_components.
209 210 211 212 213 214 |
# File 'cloud_trail/trail.rb', line 209 def get_resource_arn_attribute(arn_attr, arn_components) Jsii::Type.check_type(arn_attr, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "arnAttr") arn_components = arn_components.is_a?(Hash) ? ::AWSCDK::ARNComponents.new(**arn_components.transform_keys(&:to_sym)) : arn_components Jsii::Type.check_type(arn_components, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Bcm5Db21wb25lbnRzIn0=")), "arnComponents") jsii_call_method("getResourceArnAttribute", [arn_attr, arn_components]) end |
#get_resource_name_attribute(name_attr) ⇒ String
Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. bucket.bucketName).
Normally, this token will resolve to name_attr, but if the resource is
referenced across environments, it will be resolved to this.physicalName,
which will be a concrete name.
224 225 226 227 |
# File 'cloud_trail/trail.rb', line 224 def get_resource_name_attribute(name_attr) Jsii::Type.check_type(name_attr, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "nameAttr") jsii_call_method("getResourceNameAttribute", [name_attr]) end |
#log_all_lambda_data_events(options = nil) ⇒ void
Default: false
This method returns an undefined value.
Log all Lambda data events for all lambda functions the account.
295 296 297 298 299 |
# File 'cloud_trail/trail.rb', line 295 def log_all_lambda_data_events( = nil) = .is_a?(Hash) ? ::AWSCDK::CloudTrail::AddEventSelectorOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR0cmFpbC5BZGRFdmVudFNlbGVjdG9yT3B0aW9ucyJ9")), "options") unless .nil? jsii_call_method("logAllLambdaDataEvents", []) end |
#log_all_s3_data_events(options = nil) ⇒ void
Default: false
This method returns an undefined value.
Log all S3 data events for all objects for all buckets in the account.
307 308 309 310 311 |
# File 'cloud_trail/trail.rb', line 307 def log_all_s3_data_events( = nil) = .is_a?(Hash) ? ::AWSCDK::CloudTrail::AddEventSelectorOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR0cmFpbC5BZGRFdmVudFNlbGVjdG9yT3B0aW9ucyJ9")), "options") unless .nil? jsii_call_method("logAllS3DataEvents", []) end |
#log_group ⇒ AWSCDK::Logs::ILogGroup?
The CloudWatch log group to which CloudTrail events are sent.
undefined if send_to_cloud_watch_logs property is false.
135 136 137 |
# File 'cloud_trail/trail.rb', line 135 def log_group() jsii_get_property("logGroup") end |
#node ⇒ Constructs::Node
The tree node.
69 70 71 |
# File 'cloud_trail/trail.rb', line 69 def node() jsii_get_property("node") end |
#physical_name ⇒ String
Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.
This value will resolve to one of the following:
- a concrete value (e.g.
"my-awesome-bucket") undefined, when a name should be generated by CloudFormation- a concrete name generated automatically during synthesis, in cross-environment scenarios.
98 99 100 |
# File 'cloud_trail/trail.rb', line 98 def physical_name() jsii_get_property("physicalName") end |
#stack ⇒ AWSCDK::Stack
The stack in which this resource is defined.
105 106 107 |
# File 'cloud_trail/trail.rb', line 105 def stack() jsii_get_property("stack") end |
#to_string ⇒ String
Returns a string representation of this construct.
142 143 144 |
# File 'cloud_trail/trail.rb', line 142 def to_string() jsii_call_method("toString", []) end |
#trail_arn ⇒ String
ARN of the CloudTrail trail i.e. arn:aws:cloudtrail:us-east-2:123456789012:trail/myCloudTrail.
119 120 121 |
# File 'cloud_trail/trail.rb', line 119 def trail_arn() jsii_get_property("trailArn") end |
#trail_sns_topic_arn ⇒ String
ARN of the Amazon SNS topic that's associated with the CloudTrail trail, i.e. arn:aws:sns:us-east-2:123456789012:mySNSTopic.
126 127 128 |
# File 'cloud_trail/trail.rb', line 126 def trail_sns_topic_arn() jsii_get_property("trailSnsTopicArn") end |
#with(*mixins) ⇒ Constructs::IConstruct
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
155 156 157 158 159 160 |
# File 'cloud_trail/trail.rb', line 155 def with(*mixins) mixins.each_with_index do |item, index| Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]") end jsii_call_method("with", [*mixins]) end |