Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E3012 Specify only 'SubnetMappings' or 'Subnets' #2152

Open
sid21rane opened this issue May 3, 2023 · 1 comment
Open

E3012 Specify only 'SubnetMappings' or 'Subnets' #2152

sid21rane opened this issue May 3, 2023 · 1 comment

Comments

@sid21rane
Copy link

sid21rane commented May 3, 2023

I am using Troposphere version 3.2.2 and Python 3.7.

I want to create 2 application load balancers and I am using albv2 template for the same. One load balancer is Internet facing and another is private hence I want to attach 3 public subnets (one for each AZ) to the internet facing load balancer and 3 private subnets (one for each AZ) to the private load balancer. I am doing that with ImportValue.

While doing that I am getting an error - E3012 Specify only 'SubnetMappings' or 'Subnets'. I am using "Subnets" at both places. Ideally this shouldn't have been an issue since the subnets are different and getting attached to different load balancers. Can someone guide please.

My code -

ABCALB = elbv2.LoadBalancer(
    "ApplicationLoadBalancer",
    Scheme="internet-facing",
    SecurityGroups=[
        If("IsTrue", Ref(AlbSecurityGroupPublic), Ref(AlbSecurityGroupPrivate))
    ],
    Subnets=[
        ImportValue(
            Sub("${EnvironmentName}-ABC-vpc::PublicSubnet1a")
        ),
        ImportValue(
            Sub("${EnvironmentName}-ABC-vpc::PublicSubnet1b")
        ),
        ImportValue(
            Sub("${EnvironmentName}-ABC-vpc::PublicSubnet1c")
        ),
    ],
    Tags=get_tags(
        Sub("${EnvironmentName}-ABC-ALB"), disableDD=True
    ),
    Type="application",
    LoadBalancerAttributes=[
        elbv2.LoadBalancerAttributes(Key="access_logs.s3.enabled", Value="true"),
        elbv2.LoadBalancerAttributes(
            Key="access_logs.s3.bucket",
            Value=Sub("${EnvironmentName}-ABC-elb"),
        ),
        elbv2.LoadBalancerAttributes(
            Key="deletion_protection.enabled", Value="true"
        ),
        elbv2.LoadBalancerAttributes(
            Key="idle_timeout.timeout_seconds", Value="180"
        ),
    ],
)
template.add_resource(ABCALB)

ABCALBInternal = elbv2.LoadBalancer(
    "ApplicationInternalLoadBalancer",
    Scheme="internal",
    SecurityGroups=[
        If("IsTrue", Ref(AlbSecurityGroupPublic), Ref(AlbSecurityGroupPrivate))
    ],
    Subnets=[
        ImportValue(
            Sub("${EnvironmentName}-ABC-vpc::PrivateSubnet1a")
        ),
        ImportValue(
            Sub("${EnvironmentName}-ABC-vpc::PrivateSubnet1b")
        ),
        ImportValue(
            Sub("${EnvironmentName}-ABC-vpc::PrivateSubnet1c")
        ),
    ],
    Tags=get_tags(Sub("${EnvironmentName}ABC-internal-ALB")),
    Type="application",
    LoadBalancerAttributes=[
        elbv2.LoadBalancerAttributes(Key="access_logs.s3.enabled", Value="true"),
        elbv2.LoadBalancerAttributes(
            Key="access_logs.s3.bucket",
            Value=Sub("${EnvironmentName}-ABC-internal-elb"),
        ),
        elbv2.LoadBalancerAttributes(
            Key="deletion_protection.enabled", Value="true"
        ),
        elbv2.LoadBalancerAttributes(
            Key="idle_timeout.timeout_seconds", Value="180"
        ),
    ],
)
template.add_resource(ABCALBInternal)
@sid21rane
Copy link
Author

Hi,

Can someone help please.

regards,
Siddharth Rane

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant