diff --git a/moto/elasticbeanstalk/models.py b/moto/elasticbeanstalk/models.py
index 3767846c..13650bb2 100644
--- a/moto/elasticbeanstalk/models.py
+++ b/moto/elasticbeanstalk/models.py
@@ -2,8 +2,9 @@ import weakref
from boto3 import Session
-from moto.core import BaseBackend, BaseModel
+from moto.core import BaseBackend, BaseModel, ACCOUNT_ID
from .exceptions import InvalidParameterValueError, ResourceNotFoundException
+from .utils import make_arn
class FakeEnvironment(BaseModel):
@@ -23,15 +24,8 @@ class FakeEnvironment(BaseModel):
@property
def environment_arn(self):
- return (
- "arn:aws:elasticbeanstalk:{region}:{account_id}:"
- "environment/{application_name}/{environment_name}".format(
- region=self.region,
- account_id="123456789012",
- application_name=self.application_name,
- environment_name=self.environment_name,
- )
- )
+ resource_path = "%s/%s" % (self.application_name, self.environment_name)
+ return make_arn(self.region, ACCOUNT_ID, "environment", resource_path)
@property
def platform_arn(self):
@@ -68,6 +62,10 @@ class FakeApplication(BaseModel):
def region(self):
return self.backend.region
+ @property
+ def arn(self):
+ return make_arn(self.region, ACCOUNT_ID, "application", self.application_name)
+
class EBBackend(BaseBackend):
def __init__(self, region):
diff --git a/moto/elasticbeanstalk/responses.py b/moto/elasticbeanstalk/responses.py
index 9b6d1099..9759f71c 100644
--- a/moto/elasticbeanstalk/responses.py
+++ b/moto/elasticbeanstalk/responses.py
@@ -91,7 +91,7 @@ EB_CREATE_APPLICATION = """
- arn:aws:elasticbeanstalk:{{ region_name }}:111122223333:application/{{ application.application_name }}
+ {{ application.arn }}
{{ application.application_name }}
2019-09-03T13:08:29.049Z
@@ -125,7 +125,7 @@ EB_DESCRIBE_APPLICATIONS = """
- arn:aws:elasticbeanstalk:{{ region_name }}:111122223333:application/{{ application.application_name }}
+ {{ application.arn }}
{{ application.application_name }}
2019-09-03T13:08:29.049Z
diff --git a/moto/elasticbeanstalk/utils.py b/moto/elasticbeanstalk/utils.py
new file mode 100644
index 00000000..e3e22a11
--- /dev/null
+++ b/moto/elasticbeanstalk/utils.py
@@ -0,0 +1,11 @@
+def make_arn(region, account_id, resource_type, resource_path):
+ arn_template = (
+ "arn:aws:elasticbeanstalk:{region}:{account_id}:{resource_type}/{resource_path}"
+ )
+ arn = arn_template.format(
+ region=region,
+ account_id=account_id,
+ resource_type=resource_type,
+ resource_path=resource_path,
+ )
+ return arn
diff --git a/tests/test_elasticbeanstalk/test_eb.py b/tests/test_elasticbeanstalk/test_eb.py
index 15b8f86e..410f1862 100644
--- a/tests/test_elasticbeanstalk/test_eb.py
+++ b/tests/test_elasticbeanstalk/test_eb.py
@@ -42,6 +42,7 @@ def test_create_environment():
app = conn.create_application(ApplicationName="myapp",)
env = conn.create_environment(ApplicationName="myapp", EnvironmentName="myenv",)
env["EnvironmentName"].should.equal("myenv")
+ env["EnvironmentArn"].should.contain("myapp/myenv")
@mock_elasticbeanstalk
@@ -58,6 +59,7 @@ def test_describe_environments():
len(envs).should.equal(1)
envs[0]["ApplicationName"].should.equal("myapp")
envs[0]["EnvironmentName"].should.equal("myenv")
+ envs[0]["EnvironmentArn"].should.contain("myapp/myenv")
def tags_dict_to_list(tag_dict):