Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cdn aliases #789

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions aws/components/cdn/setup.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@
[#local aliases += [ formatDomainName(hostName, domain.Name) ] ]
[/#list]

[#list solution.Aliases as id, alias ]
[#local aliasCertificateObject = getCertificateObject(alias.Hostname) ]
[#local aliasHostName = getHostName(aliasCertificateObject, occurrence) ]

[#list aliasCertificateObject.Domains as aliasDomain ]
[#local aliases += [ formatDomainName(aliasHostName, aliasDomain)]]
[/#list]
[/#list]

[#local origins = []]
[#local cacheBehaviours = []]
[#local defaultCacheBehaviour = []]
Expand Down
28 changes: 20 additions & 8 deletions aws/components/lb/setup.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -1005,14 +1005,26 @@

[#case EC2_COMPONENT_TYPE]
[#list linkTargetResources["Zones"] as zone, resources ]
[#if getExistingReference(resources["ec2ENI"].Id, IP_ADDRESS_ATTRIBUTE_TYPE)?has_content ]
[#local staticTargets +=
getTargetGroupTarget(
"ip",
getExistingReference(resources["ec2ENI"].Id, IP_ADDRESS_ATTRIBUTE_TYPE),
destinationPort.Port,
false
)]
[#if solution.Forward.TargetType == "ip" ]
[#if getExistingReference(resources["ec2ENI"].Id, IP_ADDRESS_ATTRIBUTE_TYPE)?has_content ]
[#local staticTargets +=
getTargetGroupTarget(
"ip",
getExistingReference(resources["ec2ENI"].Id, IP_ADDRESS_ATTRIBUTE_TYPE),
destinationPort.Port,
false
)]
[/#if]
[#elseif solution.Forward.TargetType == "instance" ]
[#if getExistingReference(resources["ec2Instance"].Id)?has_content ]
[#local staticTargets +=
getTargetGroupTarget(
"instance",
getExistingReference(resources["ec2Instance"].Id),
destinationPort.Port,
false
)]
[/#if]
[/#if]
[/#list]
[#break]
Expand Down
82 changes: 82 additions & 0 deletions awstest/modules/cdn/module.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -536,4 +536,86 @@
}
]
/]

[#-- Aliases --]
[@loadModule
blueprint={
"Tiers" : {
"web" : {
"Components" : {
"cdnaliases": {
"Type": "cdn",
"deployment:Unit": "aws-cdn",
"Hostname" : {},
"Aliases": {
"env": {
"Hostname" : {
"IncludeInDomain" : {
"Environment" : true
},
"IncludeInHost" : {
"Environment" : false,
"Component": false,
"Host": true
},
"Host": "alias"
}
}
},
"Routes" : {
"default" : {
"PathPattern" : "_default",
"OriginSource" : "Placeholder",
"RedirectAliases" : {
"Enabled": false
}
}
},
"Profiles" : {
"Testing" : [ "cdnaliases" ]
}
}
}
}
},
"TestCases" : {
"cdnaliases" : {
"OutputSuffix" : "template.json",
"Structural" : {
"CFN" : {
"Resource" : {
"cfXwebXcdnaliases" : {
"Name" : "cfXwebXcdnaliases",
"Type" : "AWS::CloudFront::Distribution"
}
},
"Output" : [
"cfXwebXcdnaliasesXdns",
"cfXwebXcdnaliases"
]
},
"JSON" : {
"Match" : {
"Aliases" : {
"Path" : "Resources.cfXwebXcdnaliases.Properties.DistributionConfig.Aliases",
"Value" : ["cdnaliases-integration.mock.local", "alias.integration.mock.local"]
}
}
}
}
}
},
"TestProfiles" : {
"cdnaliases" : {
"cdn" : {
"TestCases" : [ "cdnaliases" ]
},
"*" : {
"TestCases" : [ "_cfn-lint" ]
}
}
}
}

/]
[/#macro]