Merge pull request #865 from adamstauffer/master

update RDS responses to return DBInstanceArn
This commit is contained in:
Steve Pulec 2017-03-14 23:28:30 -04:00 committed by GitHub
commit 0df47574ab
4 changed files with 39 additions and 20 deletions

View File

@ -44,3 +44,4 @@ Moto is written by Steve Pulec with contributions from:
* [Jean-Baptiste Barth](https://github.com/jbbarth)
* [Tom Viner](https://github.com/tomviner)
* [Justin Wiley](https://github.com/SectorNine50)
* [Adam Stauffer](https://github.com/adamstauffer)

View File

@ -71,6 +71,11 @@ class Database(BaseModel):
# DBParameterGroupName
# VpcSecurityGroupIds.member.N
@property
def db_instance_arn(self):
return "arn:aws:rds:{0}:1234567890:db:{1}".format(
self.region, self.db_instance_identifier)
@property
def physical_resource_id(self):
return self.db_instance_identifier
@ -231,6 +236,7 @@ class Database(BaseModel):
<Address>{{ database.address }}</Address>
<Port>{{ database.port }}</Port>
</Endpoint>
<DBInstanceArn>{{ database.db_instance_arn }}</DBInstanceArn>
</DBInstance>""")
return template.render(database=self)

View File

@ -95,6 +95,11 @@ class Database(BaseModel):
self.character_set_name = kwargs.get('character_set_name', None)
self.tags = kwargs.get('tags', [])
@property
def db_instance_arn(self):
return "arn:aws:rds:{0}:1234567890:db:{1}".format(
self.region, self.db_instance_identifier)
@property
def physical_resource_id(self):
return self.db_instance_identifier
@ -206,6 +211,7 @@ class Database(BaseModel):
<Address>{{ database.address }}</Address>
<Port>{{ database.port }}</Port>
</Endpoint>
<DBInstanceArn>{{ database.db_instance_arn }}</DBInstanceArn>
</DBInstance>""")
return template.render(database=self)
@ -349,7 +355,8 @@ class Database(BaseModel):
"Status": "active",
"VpcSecurityGroupId": "sg-123456"
}
]
],
"DBInstanceArn": "{{ database.db_instance_arn }}"
}""")
return template.render(database=self)

View File

@ -26,6 +26,8 @@ def test_create_database():
database['DBInstance']['MasterUsername'].should.equal("root")
database['DBInstance']['DBSecurityGroups'][0][
'DBSecurityGroupName'].should.equal('my_sg')
database['DBInstance']['DBInstanceArn'].should.equal(
'arn:aws:rds:us-west-2:1234567890:db:db-master-1')
@disable_on_py3()
@ -59,6 +61,8 @@ def test_get_databases():
list(instances['DBInstances']).should.have.length_of(1)
instances['DBInstances'][0][
'DBInstanceIdentifier'].should.equal("db-master-1")
instances['DBInstances'][0]['DBInstanceArn'].should.equal(
'arn:aws:rds:us-west-2:1234567890:db:db-master-1')
@disable_on_py3()
@ -333,26 +337,27 @@ def test_list_tags_db():
result = conn.list_tags_for_resource(
ResourceName='arn:aws:rds:us-west-2:1234567890:db:foo')
result['TagList'].should.equal([])
conn.create_db_instance(DBInstanceIdentifier='db-with-tags',
AllocatedStorage=10,
DBInstanceClass='postgres',
Engine='db.m1.small',
MasterUsername='root',
MasterUserPassword='hunter2',
Port=1234,
DBSecurityGroups=['my_sg'],
Tags=[
{
'Key': 'foo',
'Value': 'bar',
},
{
'Key': 'foo1',
'Value': 'bar1',
},
])
test_instance = conn.create_db_instance(
DBInstanceIdentifier='db-with-tags',
AllocatedStorage=10,
DBInstanceClass='postgres',
Engine='db.m1.small',
MasterUsername='root',
MasterUserPassword='hunter2',
Port=1234,
DBSecurityGroups=['my_sg'],
Tags=[
{
'Key': 'foo',
'Value': 'bar',
},
{
'Key': 'foo1',
'Value': 'bar1',
},
])
result = conn.list_tags_for_resource(
ResourceName='arn:aws:rds:us-west-2:1234567890:db:db-with-tags')
ResourceName=test_instance['DBInstance']['DBInstanceArn'])
result['TagList'].should.equal([{'Value': 'bar',
'Key': 'foo'},
{'Value': 'bar1',