Hi all.
I was trying to redirect from http to https via CloudFormation in AWS. AWS says this feature has been released already [1]. The official documentation about it can be found here [2].
However, when deploying via CFN, I get the following error: "You cannot specify 'target group ARN' for actions of type 'redirect'"
After speaking with a CloudFormation support expert, turns out there is a problem
. You can only do that now from the console, not via CFN.
It is not possible to set the Listener type as “Redirect” at this stage, which is needed when redirecting to https. Only “forward” works.
There is already a feature request for this in place. If you guys could help [3]. ![]()
[3] https://forums.aws.amazon.com/thread.jspa?messageID=880333
UPDATE 2018-12-07:
Thanks to @daxlreod, turns out the AWS documentation is not quite correct, plus they need to get their staff better training.
All I needed to do was to have two listeners, like this:
"ALBListenerHTTP" : {
"Type" : "AWS::ElasticLoadBalancingV2::Listener",
"Properties" : {
"DefaultActions" : [{
"Type" : "redirect",
"RedirectConfig" : {
"Host" : "#{host}",
"Path" : "/#{path}",
"Port" : "443",
"Protocol" : "HTTPS",
"Query" : "#{query}",
"StatusCode" : "HTTP_302"
},
}],
"LoadBalancerArn" : { "Ref" : "ELBRESOURCE" },
"Port" : "80",
"Protocol" : "HTTP"
}
},
"ALBListener" : {
"Type" : "AWS::ElasticLoadBalancingV2::Listener",
"Properties" : {
"DefaultActions" : [{
"Type" : "forward",
"TargetGroupArn" : { "Ref" : "ALBTargetGroup" }
}],
"LoadBalancerArn" : { "Ref" : "ELBRESOURCE" },
"SslPolicy": "ELBSecurityPolicy-2016-08",
"Certificates": [
{
"CertificateArn": { "Ref" : "SSLCertificateId" }
}
],
"Port" : "443",
"Protocol" : "HTTPS"
}
},
That works! Thanks @daxlreod.
Related discussions: