Class: AWSCDK::CfnCreationPolicy

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
cfn_creation_policy.rb

Overview

Associate the CreationPolicy attribute with a resource to prevent its status from reaching create complete until AWS CloudFormation receives a specified number of success signals or the timeout period is exceeded.

To signal a resource, you can use the cfn-signal helper script or SignalResource API. AWS CloudFormation publishes valid signals to the stack events so that you track the number of signals sent.

The creation policy is invoked only when AWS CloudFormation creates the associated resource. Currently, the only AWS CloudFormation resources that support creation policies are AWS::AutoScaling::AutoScalingGroup, AWS::EC2::Instance, AWS::CloudFormation::WaitCondition and AWS::AppStream::Fleet.

Use the CreationPolicy attribute when you want to wait on resource configuration actions before stack creation proceeds. For example, if you install and configure software applications on an EC2 instance, you might want those applications to be running before proceeding. In such cases, you can add a CreationPolicy attribute to the instance, and then send a success signal to the instance after the applications are installed and configured. For a detailed example, see Deploying Applications on Amazon EC2 with AWS CloudFormation.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auto_scaling_creation_policy: nil, resource_signal: nil, start_fleet: nil) ⇒ CfnCreationPolicy

Returns a new instance of CfnCreationPolicy.

Parameters:

  • auto_scaling_creation_policy (AWSCDK::CfnResourceAutoScalingCreationPolicy, nil) (defaults to: nil)

    For an Auto Scaling group replacement update, specifies how many instances must signal success for the update to succeed.

  • resource_signal (AWSCDK::CfnResourceSignal, nil) (defaults to: nil)

    When AWS CloudFormation creates the associated resource, configures the number of required success signals and the length of time that AWS CloudFormation waits for those signals.

  • start_fleet (Boolean, nil) (defaults to: nil)

    For an AppStream Fleet creation, specifies that the fleet is started after creation.



24
25
26
27
28
29
30
31
# File 'cfn_creation_policy.rb', line 24

def initialize(auto_scaling_creation_policy: nil, resource_signal: nil, start_fleet: nil)
  @auto_scaling_creation_policy = auto_scaling_creation_policy.is_a?(Hash) ? ::AWSCDK::CfnResourceAutoScalingCreationPolicy.new(**auto_scaling_creation_policy.transform_keys(&:to_sym)) : auto_scaling_creation_policy
  Jsii::Type.check_type(@auto_scaling_creation_policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5DZm5SZXNvdXJjZUF1dG9TY2FsaW5nQ3JlYXRpb25Qb2xpY3kifQ==")), "autoScalingCreationPolicy") unless @auto_scaling_creation_policy.nil?
  @resource_signal = resource_signal.is_a?(Hash) ? ::AWSCDK::CfnResourceSignal.new(**resource_signal.transform_keys(&:to_sym)) : resource_signal
  Jsii::Type.check_type(@resource_signal, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5DZm5SZXNvdXJjZVNpZ25hbCJ9")), "resourceSignal") unless @resource_signal.nil?
  @start_fleet = start_fleet
  Jsii::Type.check_type(@start_fleet, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "startFleet") unless @start_fleet.nil?
end

Instance Attribute Details

#auto_scaling_creation_policyAWSCDK::CfnResourceAutoScalingCreationPolicy? (readonly)

For an Auto Scaling group replacement update, specifies how many instances must signal success for the update to succeed.



36
37
38
# File 'cfn_creation_policy.rb', line 36

def auto_scaling_creation_policy
  @auto_scaling_creation_policy
end

#resource_signalAWSCDK::CfnResourceSignal? (readonly)

When AWS CloudFormation creates the associated resource, configures the number of required success signals and the length of time that AWS CloudFormation waits for those signals.

Returns:



40
41
42
# File 'cfn_creation_policy.rb', line 40

def resource_signal
  @resource_signal
end

#start_fleetBoolean? (readonly)

For an AppStream Fleet creation, specifies that the fleet is started after creation.

Returns:

  • (Boolean, nil)


44
45
46
# File 'cfn_creation_policy.rb', line 44

def start_fleet
  @start_fleet
end

Class Method Details

.jsii_propertiesObject



46
47
48
49
50
51
52
# File 'cfn_creation_policy.rb', line 46

def self.jsii_properties
  {
    :auto_scaling_creation_policy => "autoScalingCreationPolicy",
    :resource_signal => "resourceSignal",
    :start_fleet => "startFleet",
  }
end

Instance Method Details

#to_jsiiObject



54
55
56
57
58
59
60
61
62
# File 'cfn_creation_policy.rb', line 54

def to_jsii
  result = {}
  result.merge!({
    "autoScalingCreationPolicy" => @auto_scaling_creation_policy,
    "resourceSignal" => @resource_signal,
    "startFleet" => @start_fleet,
  })
  result.compact
end