AWS::Lightsail::Distribution "Resource of type 'Distribution' with identifier already exists."
Name of the resource
AWS::Lightsail::Distribution
Resource Name
AWS::Lightsail::Distribution
Issue Description
Stated that there aren't any Lightsail distribution configured:


Deploying AWS::Lightsail::Distribution using the template below throws this error:
Resource handler returned message: "Resource of type 'Distribution' with identifier 'distribution-2' already exists."
WebAppCDN:
Type: AWS::Lightsail::Distribution
Properties:
BundleId: small_1_0
CacheBehaviors:
-
Behavior: cache
Path: _next/static/*
-
Behavior: cache
Path: _next/image*
CacheBehaviorSettings:
AllowedHTTPMethods: GET,HEAD
CachedHTTPMethods: GET,HEAD
DefaultTTL: 500
#ForwardedCookies:
# CookieObject
#ForwardedHeaders:
# HeaderObject
#ForwardedQueryStrings:
# QueryStringObject
MaximumTTL: 1800
MinimumTTL: 60
#CertificateName: String
DefaultCacheBehavior:
Behavior: dont-cache
DistributionName: distribution-2
#IpAddressType: ipv4
IsEnabled: true
Origin:
Name: my-webapp-service
#Region: eu-central-1
Changing DistributionName values does not work.
Expected Behavior
The expected behavior is the ability to deploy the resource.
Observed Behavior
There isn't a DistributionName value that cloudformation accepts and the parameter is mandatory.
Test Cases
Origin my-webapp-service must exists and in my case is a LightSail container service.
AWSTemplateFormatVersion: "2010-09-09"
Description: >
LightSail CDN
Resources:
WebAppCDN:
Type: AWS::Lightsail::Distribution
Properties:
BundleId: small_1_0
CacheBehaviors:
-
Behavior: cache
Path: _next/static/*
-
Behavior: cache
Path: _next/image*
CacheBehaviorSettings:
AllowedHTTPMethods: GET,HEAD
CachedHTTPMethods: GET,HEAD
DefaultTTL: 500
#ForwardedCookies:
# CookieObject
#ForwardedHeaders:
# HeaderObject
#ForwardedQueryStrings:
# QueryStringObject
MaximumTTL: 1800
MinimumTTL: 60
#CertificateName: String
DefaultCacheBehavior:
Behavior: dont-cache
DistributionName: distribution-2
#IpAddressType: ipv4
IsEnabled: true
Origin:
Name: my-webapp-service
#Region: eu-central-1
Other Details
No response
Thanks for reporting this bug! We will be working on a fix for this. In the meantime, a quick workaround would be to create a dummy Lightsail resource in us-east-1 (any type of resource will do) before creating the CloudFormation stack with the distribution. You can delete the dummy resource after the stack is created.
This issue has been fixed!