diff --git a/moto/cloudfront/models.py b/moto/cloudfront/models.py
index 2ccf700fa..d182d2939 100644
--- a/moto/cloudfront/models.py
+++ b/moto/cloudfront/models.py
@@ -100,6 +100,8 @@ class Origin:
class DistributionConfig:
def __init__(self, config):
self.config = config
+ self.aliases = config.get("Aliases", {}).get("Items", {}).get("CNAME", [])
+ self.comment = config.get("Comment", "")
self.default_cache_behavior = DefaultCacheBehaviour(
config["DefaultCacheBehavior"]
)
@@ -145,7 +147,6 @@ class Distribution(BaseModel):
self.distribution_config = DistributionConfig(config)
self.active_trusted_signers = ActiveTrustedSigners()
self.active_trusted_key_groups = ActiveTrustedKeyGroups()
- self.aliases = []
self.origin_groups = []
self.alias_icp_recordals = []
self.last_modified_time = "2021-11-27T10:34:26.802Z"
diff --git a/moto/cloudfront/responses.py b/moto/cloudfront/responses.py
index 153b558bc..8af7efca1 100644
--- a/moto/cloudfront/responses.py
+++ b/moto/cloudfront/responses.py
@@ -381,7 +381,7 @@ DIST_CONFIG_TEMPLATE = """
{% endif %}
- {{ CommentType }}
+ {{ distribution.distribution_config.comment }}
{{ distribution.distribution_config.logging.enabled }}
{{ distribution.distribution_config.logging.include_cookies }}
diff --git a/tests/test_cloudfront/test_cloudfront_distributions.py b/tests/test_cloudfront/test_cloudfront_distributions.py
index ca33da714..104adef9c 100644
--- a/tests/test_cloudfront/test_cloudfront_distributions.py
+++ b/tests/test_cloudfront/test_cloudfront_distributions.py
@@ -121,7 +121,9 @@ def test_create_distribution_s3_minimum():
config.should.have.key("CacheBehaviors").equals({"Quantity": 0})
config.should.have.key("CustomErrorResponses").equals({"Quantity": 0})
- config.should.have.key("Comment").equals("")
+ config.should.have.key("Comment").equals(
+ "an optional comment that's not actually optional"
+ )
config.should.have.key("Logging")
logging = config["Logging"]
@@ -149,6 +151,21 @@ def test_create_distribution_s3_minimum():
restriction.should.have.key("Quantity").equals(0)
+@mock_cloudfront
+def test_create_distribution_with_additional_fields():
+ client = boto3.client("cloudfront", region_name="us-west-1")
+
+ config = example_distribution_config("ref")
+ config["Aliases"] = {"Quantity": 2, "Items": ["alias1", "alias2"]}
+ resp = client.create_distribution(DistributionConfig=config)
+ distribution = resp["Distribution"]
+ distribution.should.have.key("DistributionConfig")
+ config = distribution["DistributionConfig"]
+ config.should.have.key("Aliases").equals(
+ {"Items": ["alias1", "alias2"], "Quantity": 2}
+ )
+
+
@mock_cloudfront
def test_create_distribution_returns_etag():
client = boto3.client("cloudfront", region_name="us-east-1")