I'm testing a code on getting an existing security...
# general
I'm testing a code on getting an existing security group using the
api/method from https://www.pulumi.com/registry/packages/aws/api-docs/ec2/securitygroup/ What is provider id? I'm currently on EC2 security group console specifically on the existing sg but I can't figure out what provider is.
I figured it out. It's the security group id. The provider id from the documentation confused me. Maybe it can be updated to
You’re right, the documentation could probably be a bit clearer on what “provider ID” really is. There’s oblique reference to this in https://www.pulumi.com/docs/intro/concepts/resources/names/#resource-names (as the physical name), and further clarification in https://www.pulumi.com/docs/intro/concepts/resources/get/, but the term “provider ID” isn’t defined anywhere (or, IIRC, used entirely consistently).
Thank you
Do you know why Pulumi decided to make resource_name, id mandatory when we can use tags when doing a SecurityGroup.get()? We're using terraform data and we only supply tags to find the resource property like id, arn, etc.
Are you looking for this maybe? https://www.pulumi.com/registry/packages/aws/api-docs/ec2/getsecuritygroups/ It’s an
resource method; not immediately intuitive, but appears to be a common pattern for AWS constructions in Pulumi.
This is my code. I'll check your link now
Copy code
# Retrieve the security group object by name
existing_security_group = aws.ec2.SecurityGroup.get(
    tags={"name": existing_security_group_name},
yeah, looks like that's what I want
Should I stop using the code I pasted?
I'm trying to reference my_sg inside aws.ec2.Instance but I'm getting an error referencing it with
Copy code
my_sg = aws.ec2.get_security_groups(tags={
    "name": "myhttp-sg",

instance = aws.ec2.Instance(
and error
Copy code
error: 1 error occurred:
    	* creating EC2 Instance: InvalidParameterValue: Value () for parameter groupId is invalid. The value cannot be empty
    	status code: 400, request id: 9f7a42d7-f64b-376a-8e10-bde2445d4770
I'm good. I got it working. I had to use ids property and set index to zero
Yes, it’s a list, so there’s a need to encode the assumption that it should only ever match one resource in your case (you may indeed want some sort of code to check for that), or you could just attach all SGs that you get back (which is more generalized, but may swallow a misconfiguration if you will never be needing that in your use case).
Yep, was thinking about that too. Thank you.
Didn't read the whole thread, but this is a common problem point of confusion. The ID is always the same as the value for
, so just check the Import section of the docs. In the meanwhile, if you could also upvote and/or comment on this issue, it would be helpful in prioritizing a fix: https://github.com/pulumi/pulumi/issues/11737