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(engine_version multi_az iops publicly_accessible db_name port db_subnet_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, #whyrun_supported?
Instance Method Details
#create_aws_object ⇒ Object
27 28 29 30 31 |
# 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 new_resource.driver.rds.client.create_db_instance() end end |
#destroy_aws_object(instance) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/chef/provider/aws_rds_instance.rb', line 33 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, query_method: :exists?, expected_responses: [false], acceptable_errors: [AWS::RDS::Errors::DBInstanceNotFound], tries: 60, sleep: 10 ) end end |
#options_hash ⇒ Object
Sets the additional options then overrides it with all required options from the resource as well as optional options
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/chef/provider/aws_rds_instance.rb', line 52 def @options_hash ||= 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 |