Merge pull request #865 from adamstauffer/master
update RDS responses to return DBInstanceArn
This commit is contained in:
commit
0df47574ab
@ -44,3 +44,4 @@ Moto is written by Steve Pulec with contributions from:
|
|||||||
* [Jean-Baptiste Barth](https://github.com/jbbarth)
|
* [Jean-Baptiste Barth](https://github.com/jbbarth)
|
||||||
* [Tom Viner](https://github.com/tomviner)
|
* [Tom Viner](https://github.com/tomviner)
|
||||||
* [Justin Wiley](https://github.com/SectorNine50)
|
* [Justin Wiley](https://github.com/SectorNine50)
|
||||||
|
* [Adam Stauffer](https://github.com/adamstauffer)
|
||||||
|
@ -71,6 +71,11 @@ class Database(BaseModel):
|
|||||||
# DBParameterGroupName
|
# DBParameterGroupName
|
||||||
# VpcSecurityGroupIds.member.N
|
# 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
|
@property
|
||||||
def physical_resource_id(self):
|
def physical_resource_id(self):
|
||||||
return self.db_instance_identifier
|
return self.db_instance_identifier
|
||||||
@ -231,6 +236,7 @@ class Database(BaseModel):
|
|||||||
<Address>{{ database.address }}</Address>
|
<Address>{{ database.address }}</Address>
|
||||||
<Port>{{ database.port }}</Port>
|
<Port>{{ database.port }}</Port>
|
||||||
</Endpoint>
|
</Endpoint>
|
||||||
|
<DBInstanceArn>{{ database.db_instance_arn }}</DBInstanceArn>
|
||||||
</DBInstance>""")
|
</DBInstance>""")
|
||||||
return template.render(database=self)
|
return template.render(database=self)
|
||||||
|
|
||||||
|
@ -95,6 +95,11 @@ class Database(BaseModel):
|
|||||||
self.character_set_name = kwargs.get('character_set_name', None)
|
self.character_set_name = kwargs.get('character_set_name', None)
|
||||||
self.tags = kwargs.get('tags', [])
|
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
|
@property
|
||||||
def physical_resource_id(self):
|
def physical_resource_id(self):
|
||||||
return self.db_instance_identifier
|
return self.db_instance_identifier
|
||||||
@ -206,6 +211,7 @@ class Database(BaseModel):
|
|||||||
<Address>{{ database.address }}</Address>
|
<Address>{{ database.address }}</Address>
|
||||||
<Port>{{ database.port }}</Port>
|
<Port>{{ database.port }}</Port>
|
||||||
</Endpoint>
|
</Endpoint>
|
||||||
|
<DBInstanceArn>{{ database.db_instance_arn }}</DBInstanceArn>
|
||||||
</DBInstance>""")
|
</DBInstance>""")
|
||||||
return template.render(database=self)
|
return template.render(database=self)
|
||||||
|
|
||||||
@ -349,7 +355,8 @@ class Database(BaseModel):
|
|||||||
"Status": "active",
|
"Status": "active",
|
||||||
"VpcSecurityGroupId": "sg-123456"
|
"VpcSecurityGroupId": "sg-123456"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"DBInstanceArn": "{{ database.db_instance_arn }}"
|
||||||
}""")
|
}""")
|
||||||
return template.render(database=self)
|
return template.render(database=self)
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ def test_create_database():
|
|||||||
database['DBInstance']['MasterUsername'].should.equal("root")
|
database['DBInstance']['MasterUsername'].should.equal("root")
|
||||||
database['DBInstance']['DBSecurityGroups'][0][
|
database['DBInstance']['DBSecurityGroups'][0][
|
||||||
'DBSecurityGroupName'].should.equal('my_sg')
|
'DBSecurityGroupName'].should.equal('my_sg')
|
||||||
|
database['DBInstance']['DBInstanceArn'].should.equal(
|
||||||
|
'arn:aws:rds:us-west-2:1234567890:db:db-master-1')
|
||||||
|
|
||||||
|
|
||||||
@disable_on_py3()
|
@disable_on_py3()
|
||||||
@ -59,6 +61,8 @@ def test_get_databases():
|
|||||||
list(instances['DBInstances']).should.have.length_of(1)
|
list(instances['DBInstances']).should.have.length_of(1)
|
||||||
instances['DBInstances'][0][
|
instances['DBInstances'][0][
|
||||||
'DBInstanceIdentifier'].should.equal("db-master-1")
|
'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()
|
@disable_on_py3()
|
||||||
@ -333,26 +337,27 @@ def test_list_tags_db():
|
|||||||
result = conn.list_tags_for_resource(
|
result = conn.list_tags_for_resource(
|
||||||
ResourceName='arn:aws:rds:us-west-2:1234567890:db:foo')
|
ResourceName='arn:aws:rds:us-west-2:1234567890:db:foo')
|
||||||
result['TagList'].should.equal([])
|
result['TagList'].should.equal([])
|
||||||
conn.create_db_instance(DBInstanceIdentifier='db-with-tags',
|
test_instance = conn.create_db_instance(
|
||||||
AllocatedStorage=10,
|
DBInstanceIdentifier='db-with-tags',
|
||||||
DBInstanceClass='postgres',
|
AllocatedStorage=10,
|
||||||
Engine='db.m1.small',
|
DBInstanceClass='postgres',
|
||||||
MasterUsername='root',
|
Engine='db.m1.small',
|
||||||
MasterUserPassword='hunter2',
|
MasterUsername='root',
|
||||||
Port=1234,
|
MasterUserPassword='hunter2',
|
||||||
DBSecurityGroups=['my_sg'],
|
Port=1234,
|
||||||
Tags=[
|
DBSecurityGroups=['my_sg'],
|
||||||
{
|
Tags=[
|
||||||
'Key': 'foo',
|
{
|
||||||
'Value': 'bar',
|
'Key': 'foo',
|
||||||
},
|
'Value': 'bar',
|
||||||
{
|
},
|
||||||
'Key': 'foo1',
|
{
|
||||||
'Value': 'bar1',
|
'Key': 'foo1',
|
||||||
},
|
'Value': 'bar1',
|
||||||
])
|
},
|
||||||
|
])
|
||||||
result = conn.list_tags_for_resource(
|
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',
|
result['TagList'].should.equal([{'Value': 'bar',
|
||||||
'Key': 'foo'},
|
'Key': 'foo'},
|
||||||
{'Value': 'bar1',
|
{'Value': 'bar1',
|
||||||
|
Loading…
Reference in New Issue
Block a user