Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

RDS DBInstance resource #189

Closed
wants to merge 3 commits into from
Closed

Conversation

ktheory
Copy link
Contributor

@ktheory ktheory commented Jan 4, 2015

👋 Here's a simple little resource for RDS instances.

It's not complete, but it's a start.

It adds:

  • Aws::RDS::Resource#create_db_instance (returns a DBInstance)
  • Aws::RDS::Resource#db_instances (returns a collection of DBInstances)
  • Aws::RDS::DBInstance#modify
  • Aws::RDS::DBInstance#delete

Here's an example walkthrough with required arguments:

Aws::RDS::Resource.new.db_instances # Collection of DB instances

# Create a new DB instance
db  = Aws::RDS::Resource.new.create_db_instance(
  db_instance_identifier: 'example-db',
  allocated_storage: 5,
  db_instance_class: 'db.t1.micro',
  engine: 'mysql',
  master_username: 'foo',
  master_user_password: '12345678'
)

# Wait until db_instance_status is available, then modify it:
db.modify(allocated_storage: 6, apply_immediately: true)

# Shut it down
db.delete(skip_final_snapshot: true)

No errors from rake resources:validate (except an unrelated S3 issue)

Class methods on RDS::Resource
#create_db_instance
#instances

And instance methods on RDS::DBInstance:
.modify
.delete
@coveralls
Copy link

Coverage Status

Coverage decreased (-8.58%) when pulling 33f1687 on ktheory:rds-resources into b273ed8 on aws:master.

@trevorrowe
Copy link
Contributor

Sorry for the slow response. I've been out-of-the office and I am just getting back into things. I'll try to take a look at this and see about getting this merged. I'm working on a minor refactoring of the resource definition structure, but it wouldn't require many changes to make this work (very trivial ones).

@ktheory
Copy link
Contributor Author

ktheory commented Jan 7, 2015

Thanks, Trevor.

(Honestly no need to apologize. That's how it goes with OSS.)

On Jan 7, 2015, at 6:17 PM, Trevor Rowe notifications@github.com wrote:

Sorry for the slow response. I've been out-of-the office and I am just getting back into things. I'll try to take a look at this and see about getting this merged. I'm working on a minor refactoring of the resource definition structure, but it wouldn't require many changes to make this work (very trivial ones).


Reply to this email directly or view it on GitHub.

@trevorrowe
Copy link
Contributor

I've finalized the refactor of the resource definitions. There are some minor changes required for this to work again. The primary differences are:

  • All top-level resources should now have a "has" association in the "service" section of the model. This is what the SDK will use to provide methods such as rds.db_instance(id). The structure of a "has" association is the same as a "hasMany".

    {
      "service": {
        "has": {
          "DBInstance": {
            "resource": {
              "type": "DBInstance",
              "identifiers": [ ... ]
            }
          }
        }
      }
    }
  • All resource identifier lists and request parameter lists that provide a target/sourceType/source need updating. The "sourceType" attribute is now just "source", and the the previous "source" is now contextual to the source. For example:

    # old
    { "target": "DBInstanceIdentifier", "sourceType": "identifier", "source": "Id" }
    # new
    { "target": "DBInstanceIdentifier", "source": "identifier", "identifierName": "Id" }
    
    # old
    { "target": "Id", "sourceType": "responsePath", "source": "DBInstances[].DBInstanceIdentifier" }
    # new
    { "target": "Id", "source": "responsePath", "path": "DBInstances[].DBInstanceIdentifier" }

@ktheory
Copy link
Contributor Author

ktheory commented Jan 27, 2015

@trevorrowe: Updated per your comment. The walkthrough in the PR description works the same, as does Aws::RDS::Resource.new.db_instance(my_db_id).

Oh, and I figured out that identifierName should just be name in your comment. 😉.

@ktheory
Copy link
Contributor Author

ktheory commented Jan 27, 2015

Oh, and as an aside/pro-tip, I spent more time than I'd like trying to track down a JSON syntax error (missing colon).

Parsing the file as YAML gives more accurate line numbers for the error than JSON. E.g.

ruby -ryaml -e 'YAML.load_file("aws-sdk-core/apis/RDS.resources.json")'

@trevorrowe
Copy link
Contributor

This has been merged into master of aws/aws-sdk-ruby: aws/aws-sdk-ruby@496c5fc

Sorry for taking a while. I reached out to the RDS team to get input on the interface. I'm going to continue to expand on this interface based on their input. Hopefully we can cover the full RDS interface.

Thanks again!

@trevorrowe trevorrowe closed this Feb 23, 2015
@ktheory
Copy link
Contributor Author

ktheory commented Feb 24, 2015

Yay, thanks.

On Feb 23, 2015, at 3:44 PM, Trevor Rowe notifications@github.com wrote:

Closed #189.


Reply to this email directly or view it on GitHub.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants