Class: Chef::Provider::AwsRdsInstance
- Inherits:
-
Chef::Provisioning::AWSDriver::AWSProvider
- Object
- LWRPBase
- Chef::Provisioning::AWSDriver::AWSProvider
- Chef::Provider::AwsRdsInstance
- Defined in:
- lib/chef/provider/aws_rds_instance.rb
Constant Summary collapse
- REQUIRED_OPTIONS =
i(db_instance_identifier allocated_storage engine db_instance_class master_username master_user_password)
- OTHER_OPTIONS =
i(db_snapshot_identifier engine_version multi_az iops publicly_accessible db_name port db_subnet_group_name db_parameter_group_name)
Constants inherited from Chef::Provisioning::AWSDriver::AWSProvider
Chef::Provisioning::AWSDriver::AWSProvider::AWSResource
Instance Attribute Summary
Attributes inherited from Chef::Provisioning::AWSDriver::AWSProvider
Instance Method Summary collapse
- #create_aws_object ⇒ Object
- #destroy_aws_object(instance) ⇒ Object
-
#options_hash ⇒ Object
Sets the additional options then overrides it with all required options from the resource as well as optional options.
- #update_aws_object(instance) ⇒ Object
Methods included from Chef::Provisioning::AWSDriver::TaggingStrategy::RDSConvergeTags
#aws_tagger, #construct_arn, #converge_tags
Methods inherited from Chef::Provisioning::AWSDriver::AWSProvider
#action_handler, #converge_by, #region, retry_with_backoff, #whyrun_supported?
Instance Method Details
#create_aws_object ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/chef/provider/aws_rds_instance.rb', line 27 def create_aws_object converge_by "create RDS instance #{new_resource.db_instance_identifier} in #{region}" do if new_resource.db_snapshot_identifier = [:allocated_storage, :master_username, :master_user_password, :engine_version].each { |k| .delete(k) } new_resource.driver.rds_client.restore_db_instance_from_db_snapshot().db_instance else new_resource.driver.rds_resource.create_db_instance() end end end |
#destroy_aws_object(instance) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/chef/provider/aws_rds_instance.rb', line 38 def destroy_aws_object(instance) converge_by "delete RDS instance #{new_resource.db_instance_identifier} in #{region}" do instance.delete(skip_final_snapshot: true) end # Wait up to 10 minutes for the db instance to shutdown converge_by "waited until RDS instance #{new_resource.name} was deleted" do wait_for( aws_object: instance, # http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.Status.html # It cannot _actually_ return a deleted status, we're just looking for the error query_method: :db_instance_status, expected_responses: ['deleted'], acceptable_errors: [::Aws::RDS::Errors::DBInstanceNotFound], tries: 60, sleep: 10 ) { |instance| instance.reload } end end |
#options_hash ⇒ Object
Sets the additional options then overrides it with all required options from the resource as well as optional options
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/chef/provider/aws_rds_instance.rb', line 59 def ||= begin opts = Hash[new_resource..map{|(k,v)| [k.to_sym,v]}] REQUIRED_OPTIONS.each do |opt| opts[opt] = new_resource.send(opt) end OTHER_OPTIONS.each do |opt| opts[opt] = new_resource.send(opt) if ! new_resource.send(opt).nil? end AWSResource.(opts, resource: new_resource) opts end end |
#update_aws_object(instance) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/chef/provider/aws_rds_instance.rb', line 14 def update_aws_object(instance) Chef::Log.warn("aws_rds_instance does not support modifying a started instance") # There are required optiosn (like `allocated_storage`) that the use may not # specify on a resource to perform an update. For example, they may want to # only specify iops to modify that attribute on an update after initial # creation. In this case we need to load the required options from the existing # aws_object and only override it if the user has specified a value in the # resource. Ideally, it would be nice to mark values as required on the # resource but right now there is not a `required_on_create`. This would # also be different if chef-provisioning performed resource cloning, which # it does not. end |