Add missing information in SSM parameters

This commit is contained in:
Emile Fugulin 2019-11-30 20:03:51 -05:00
commit b52fa636b6
4 changed files with 47 additions and 5 deletions

View file

@ -13,6 +13,7 @@ import time
import uuid
import itertools
from .utils import parameter_arn
from .exceptions import (
ValidationException,
InvalidFilterValue,
@ -60,19 +61,23 @@ class Parameter(BaseModel):
if value.startswith(prefix):
return value[len(prefix) :]
def response_object(self, decrypt=False):
def response_object(self, decrypt=False, region=None):
r = {
"Name": self.name,
"Type": self.type,
"Value": self.decrypt(self.value) if decrypt else self.value,
"Version": self.version,
"LastModifiedDate": round(self.last_modified_date, 3),
}
if region:
r["ARN"] = parameter_arn(region, self.name)
return r
def describe_response_object(self, decrypt=False):
r = self.response_object(decrypt)
r["LastModifiedDate"] = int(self.last_modified_date)
r["LastModifiedDate"] = round(self.last_modified_date, 3)
r["LastModifiedUser"] = "N/A"
if self.description:

View file

@ -51,7 +51,7 @@ class SimpleSystemManagerResponse(BaseResponse):
}
return json.dumps(error), dict(status=400)
response = {"Parameter": result.response_object(with_decryption)}
response = {"Parameter": result.response_object(with_decryption, self.region)}
return json.dumps(response)
def get_parameters(self):
@ -63,7 +63,7 @@ class SimpleSystemManagerResponse(BaseResponse):
response = {"Parameters": [], "InvalidParameters": []}
for parameter in result:
param_data = parameter.response_object(with_decryption)
param_data = parameter.response_object(with_decryption, self.region)
response["Parameters"].append(param_data)
param_names = [param.name for param in result]
@ -85,7 +85,7 @@ class SimpleSystemManagerResponse(BaseResponse):
response = {"Parameters": []}
for parameter in result:
param_data = parameter.response_object(with_decryption)
param_data = parameter.response_object(with_decryption, self.region)
response["Parameters"].append(param_data)
return json.dumps(response)

4
moto/ssm/utils.py Normal file
View file

@ -0,0 +1,4 @@
def parameter_arn(region, parameter_name):
if parameter_name[0] == "/":
parameter_name = parameter_name[1:]
return "arn:aws:ssm:{0}:1234567890:parameter/{1}".format(region, parameter_name)