polite-napkin-90098
01/04/2022, 5:36 PM./main.go:153:22: sg.Id undefined (type *ec2.SecurityGroup has no field or method Id)
I'll post my code as a thread to avoid clutter.sg, err := ec2.NewSecurityGroup(ctx, "EKS", &ec2.SecurityGroupArgs{
Description: pulumi.String("Group for the EKS cluster"),
VpcId: pulumi.String(vpcid),
Ingress: ec2.SecurityGroupIngressArray{
// Allow ssh in from the ssh hosts
&ec2.SecurityGroupIngressArgs{
Description: pulumi.String("ssh in from the ssh-hosts"),
FromPort: <http://pulumi.Int|pulumi.Int>(22),
ToPort: <http://pulumi.Int|pulumi.Int>(22),
Protocol: pulumi.String("tcp"),
SecurityGroups: pulumi.StringArray{
pulumi.String("sg-0f61cce3d6946c140"), // This needs to be looked up as this is the Test one
},
},
},
Egress: ec2.SecurityGroupEgressArray{
// allow https out to anywhere
&ec2.SecurityGroupEgressArgs{
FromPort: <http://pulumi.Int|pulumi.Int>(443),
ToPort: <http://pulumi.Int|pulumi.Int>(443),
Protocol: pulumi.String("tcp"),
CidrBlocks: pulumi.StringArray{
pulumi.String("0.0.0.0/0"),
},
Ipv6CidrBlocks: pulumi.StringArray{
pulumi.String("::/0"),
},
},
},
Tags: pulumi.StringMap{
"Name": pulumi.String("Test-EKS"), // needs to be compiled from the VPC and -EKS
},
})
// Create an EKS cluster with the default configuration.
cluster, err := eks.NewCluster(ctx, "Test", &eks.ClusterArgs{
ResourcesVpcConfig: &eks.ClusterResourcesVpcConfigArgs{
SubnetIds: pulumi.StringArray{
pulumi.String(private[0]),
pulumi.String(private[1]),
pulumi.String(private[2]),
},
EndpointPrivateAccess: pulumi.Bool(true),
EndpointPublicAccess: pulumi.Bool(false),
SecurityGroupIds: pulumi.StringArray{
sg.Id,
},
},
RoleArn: eksRole.Arn,
})
if err != nil {
return err
}
These are the blocks where I create the sg and try to use the Id in the EKS cluster block.
I can get the Arn, with sg.Arn or the account id with sg.OwnerIdbillowy-army-68599
01/04/2022, 6:28 PMsg.ID()
polite-napkin-90098
01/04/2022, 6:34 PM