https://pulumi.com logo
#general
Title
# general
s

sparse-tiger-67367

01/23/2019, 6:06 PM
Good morning, I'm having trouble using pulumi with go + aws. I'm trying to create a security group and then use it's ID in another security group's Ingress rule but I keep getting an error like this:
error: aws:ec2/securityGroup:SecurityGroup resource 'sg1' has a problem: ingress.0: invalid or unknown key: source_security_group_id
Can anybody help me figure this one out?
g

gentle-diamond-70147

01/23/2019, 6:32 PM
Can you share your code?
s

sparse-tiger-67367

01/23/2019, 6:36 PM
Copy code
publicSecurityGroup, err := ec2.NewSecurityGroup(ctx, "sg1", &ec2.SecurityGroupArgs{
			Description: "For inter-security group traffic",
			VpcId:       vpc.ID(),
			Ingress: []map[string]interface{}{
				{
					"protocol":   "tcp",
					"fromPort":   22,
					"toPort":     22,
					"cidrBlocks": []string{"0.0.0.0/0"},
				},
			},
		})

		privateSecurityGroup, err := ec2.NewSecurityGroup(ctx, "sg2", &ec2.SecurityGroupArgs{
			Description: "For intra-security group traffic",
			Ingress: []map[string]interface{}{
				{
					"protocol": "tcp",
					"fromPort": 0,
					"toPort":   65535,
					"sourceSecurityGroupId": publicSecurityGroup.ID(),
				},
			},
		})
g

gentle-diamond-70147

01/23/2019, 6:58 PM
for inline ingress rules, I believe you want
securityGroups
instead of
sourceSecurityGroupId
sourceSecurityGroupId
is used for
SecurityGroupRule
resources
s

sparse-tiger-67367

01/24/2019, 6:02 PM
Awesome that worked - thanks!
👍 1