https://pulumi.com logo
#typescript
Title
# typescript
c

cuddly-family-16114

02/27/2024, 4:04 PM
Good Morning, I'm experiencing an issue where an ASG I'm creating is saying the Launch Template isn't valid with the following error:
Value () for parameter groupId is invalid.
I've got a simplified version of my code below. Can someone tell me what I'm missing? I've tried everything including
vpcSecurityGroups
,
securityGroupNames
,
networkInterfaces:securityGroups
as well as doing getSecurityGroup requests instead.
Copy code
const group1s = new aws.ec2.SecurityGroup("secgrp-1s", {
  vpcId: defaultVpcId,
  description: "Enable HTTPS access",
  ingress: [{
    protocol: "tcp",
    fromPort: 443,
    toPort: 443,
    cidrBlocks: ["0.0.0.0/0"],
  }],
  egress: [{
    protocol: "-1",
    fromPort: 0,
    toPort: 0,
    cidrBlocks: ["0.0.0.0/0"],
  }],
}, {dependsOn: [appVpc]})

const launchTemplate = new aws.ec2.LaunchTemplate("spot-lt", {
  imageId: "ami-0f93c02efd1974b8b",
  instanceType: instanceType ?? "t3.micro",
  vpcSecurityGroupIds: [group1s.id],
}, {dependsOn: [group1s]})

const autoScalingGroup = new aws.autoscaling.Group("spot-asg", {
  desiredCapacity: desiredCapacity ?? 1,
  minSize: minSize ?? 1,
  maxSize: maxSize ?? 1,
  availabilityZones: ["us-east-1a", "us-east-1b"],
  mixedInstancesPolicy:{
    instancesDistribution: {
      onDemandBaseCapacity: onDemandBaseCapacity ?? 1,
      onDemandPercentageAboveBaseCapacity: onDemandPercentageAboveBaseCapacity ?? 0,
      spotAllocationStrategy: "lowest-price",
    },
    launchTemplate: {
      launchTemplateSpecification:{
        launchTemplateId: launchTemplate.id,
        
      },
    },
  },
}, {dependsOn: [launchTemplate, group1s]})
Going a little nuts figuring out what I missed
f

fast-vase-27755

02/27/2024, 5:18 PM
maybe you have oversimplified it but I do not see you providing
groupId
at all hence empty value is invalid
c

cuddly-family-16114

02/27/2024, 6:06 PM
There is no value allowed for Group ID that I can find for
aws.ec2.LaunchTemplate
https://www.pulumi.com/registry/packages/aws/api-docs/ec2/launchtemplate/#inputs
f

fast-vase-27755

02/27/2024, 6:10 PM
right, in TS it is also ensured that all required parameters are present
c

cuddly-family-16114

02/27/2024, 6:10 PM
Full error:
Copy code
creating Auto Scaling Group (spot-asg-232abd0): ValidationError: You must use a valid fully-formed launch template. Value () for parameter groupId is invalid. The value cannot be empty
f

fast-vase-27755

02/27/2024, 6:24 PM
so error is in last statement, and
Copy code
launchTemplate: {
      launchTemplateSpecification:{
        launchTemplateId: launchTemplate.id,
        
      },
    },
is malformed this is a tricky one, do you see launch template created? I also noticed that you have dependency loop for
autoScalingGroup
.. I do not think you need dependsOn statement here at all
c

cuddly-family-16114

02/27/2024, 6:26 PM
Sorry, that look is not actually there in my actual code.
yes, the launch template is created (& updated with each test) successfully
f

fast-vase-27755

02/27/2024, 6:29 PM
I wish I ever deployed ec2 ASGs with pulumi, but gone serverless long time, sorry about that
c

cuddly-family-16114

02/27/2024, 6:30 PM
how is the
launchTemplateSpecification
malformed? I'm not doing any overrides, so there shouldn't be anything there.
f

fast-vase-27755

02/27/2024, 6:30 PM
what I usually do in this situation - go with debugger inside pulumi internals and see actual checks
c

cuddly-family-16114

02/27/2024, 6:31 PM
I wish I ever deployed ec2 ASGs with pulumi
Don't worry about it, appreciate the help. I'm trying to come over from terraform so expecting to hit roadblocks
f

fast-vase-27755

02/27/2024, 6:31 PM
or you also can download some any minimal working example and try to find differences with your code
c

cuddly-family-16114

02/27/2024, 6:37 PM
yea, I've done that. Also run through pulumi's AI & Copilot with no help too. That's why I came here
Think I figured it out. The template was being accepted, but when throwing the error only when it was being attached to the ASG. The template was invalid, but not because of the groupId, but because I grabbed the wrong AMI & it didn't work with that instance type.
f

fast-vase-27755

02/27/2024, 9:51 PM
if you believe this is bug in error message it would be great to report to pulumi for bugfix
2 Views