Giter VIP home page Giter VIP logo

Comments (5)

stanb avatar stanb commented on May 24, 2024

Hi.
I think this is what you mean:

var template = new Template
{
    Parameters = new Parameters
    {
        new Parameter
        {
            LogicalId = "NetworkStack",
            Description = "Name of network stack",
            Type = ParameterType.String
        }
    },
    Resources = new Resources
    {
        new Comformation.CloudFormation.Stack.StackResource
        {
            LogicalId = "WebsiteAndALB",
            Properties =
            {
                TemplateURL = "https://xxxx.yaml",
                Parameters = new Dictionary<string, Union<string, IntrinsicFunction>>
                {
                    { "ALBSubnets", Fn.ImportValue(Fn.Sub("${NetworkStack}-PublicSubnets")) }
                }
            }
        }
    }
};

from comformation.

pmacca avatar pmacca commented on May 24, 2024

kinda... the part I can't get the syntax on is replicating this:

Subnets: !Ref ALBSubnets

I'm trying to recreate it like this somehow...

            var loadBalancer = new Comformation.ElasticLoadBalancingV2.LoadBalancer.LoadBalancerResource()
            {
                Properties =
                {
                    Name = EnvironmentName,
                    Subnets = new List<Dictionary<string, Union<string, IntrinsicFunction>>>
                    {
                        Fn.Ref("ALBSubnets") /// ??? broken
                    }
                }
            };

from comformation.

stanb avatar stanb commented on May 24, 2024

The syntax should be

var template = new Template
{
    Parameters = new Parameters
    {
        new Parameter
        {
            LogicalId = "ALBSubnets",
            Type = ParameterType.SubnetIdList,
            Description = "Choose which subnets the Application Load Balancer should be deployed to"
        }
    },
    Resources = new Resources
    {
        new Comformation.ElasticLoadBalancingV2.LoadBalancer.LoadBalancerResource
        {
            LogicalId = "LoadBalancer",
            Properties =
            {
                Subnets = new List<Union<string, IntrinsicFunction>>
                {
                    Fn.Ref("ALBSubnets")
                }
            }
        }
    }
};

but it will generate wrong cf template. So its a bug. Thanks for finding it.
On a fast look the Subnets property type should be Union<IntrinsicFunction, List<Union<string, IntrinsicFunction>>>.
As a workaround until I fix it you can declare new resource class

public class LoadBalancerResourceFixed : Comformation.ElasticLoadBalancingV2.LoadBalancer.LoadBalancerResource
{
    public class LoadBalancerPropertiesFixed : Comformation.ElasticLoadBalancingV2.LoadBalancer.LoadBalancerResource.LoadBalancerProperties
    {
        public new Union<IntrinsicFunction, List<Union<string, IntrinsicFunction>>> Subnets { get; set; }
    }

    public new LoadBalancerResourceFixed.LoadBalancerPropertiesFixed Properties { get; } = new LoadBalancerResourceFixed.LoadBalancerPropertiesFixed(); 
}

and then you can use

var template = new Template
{
    Parameters = new Parameters
    {
        new Parameter
        {
            LogicalId = "ALBSubnets",
            Type = ParameterType.SubnetIdList,
            Description = "Choose which subnets the Application Load Balancer should be deployed to"
        }
    },
    Resources = new Resources
    {
        new LoadBalancerResourceFixed
        {
            LogicalId = "LoadBalancer",
            Properties =
            {
                Subnets = Fn.Ref("ALBSubnets")
            }
        }
    }
};

I have to think how to fix it globally without breaking backward compatibility.

from comformation.

pmacca avatar pmacca commented on May 24, 2024

from comformation.

pmacca avatar pmacca commented on May 24, 2024

This compiles. I'll keep testing and keep an eye out for your next release.
Cheers

from comformation.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.