diff --git a/aws/components/cdn/setup.ftl b/aws/components/cdn/setup.ftl index c844b7db..e09b27e7 100644 --- a/aws/components/cdn/setup.ftl +++ b/aws/components/cdn/setup.ftl @@ -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 = []] diff --git a/aws/components/lb/setup.ftl b/aws/components/lb/setup.ftl index dee85574..ddce85b6 100644 --- a/aws/components/lb/setup.ftl +++ b/aws/components/lb/setup.ftl @@ -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] diff --git a/awstest/modules/cdn/module.ftl b/awstest/modules/cdn/module.ftl index 30def989..6095ce24 100644 --- a/awstest/modules/cdn/module.ftl +++ b/awstest/modules/cdn/module.ftl @@ -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]