Skip to content

Adding Cloudfront addon fails  #1848

@vbarba

Description

@vbarba

Hi,

I am using the following template to add Cloudfront CDN in front of Load Balanced Web Service:

Parameters:
  App:
    Type: String
    Description: Your application's name.
  Env:
    Type: String
    Description: The environment name your service, job, or workflow is being deployed to.
  Name:
    Type: String
    Description: The name of the service, job, or workflow being deployed.
Resources:
  myDistribution:
    Type: 'AWS::CloudFront::Distribution'
    Properties:
      DistributionConfig:
        Origins:
        - DomainName:
            Fn::ImportValue:
              !Sub "${App}-${Env}-PublicLoadBalancerDNS"       
          Id: myCustomOrigin          
          CustomOriginConfig:
            HTTPPort: 80
            OriginProtocolPolicy: http-only
        Enabled: true
        Comment: !Sub "{$App}-${Env}-${Name}"
        DefaultCacheBehavior:
          TargetOriginId: myCustomOrigin
          ViewerProtocolPolicy: allow-all
          ForwardedValues:
            QueryString: false
            Cookies:
              Forward: all
        ViewerCertificate:
          CloudFrontDefaultCertificate: true

This works when the service was deployed before, but fails if this is deployed together for the first time because the

           Fn::ImportValue:
              !Sub "${App}-${Env}-PublicLoadBalancerDNS" 

Is not available until de Load Balanced Service is deployed.

Do you have any advice with this situation?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugIssues that are bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions