https://pulumi.com logo
Title
e

enough-leather-70274

03/09/2021, 6:06 AM
I found the docs for SecurityGroupRule, but the examples seem a bit mangled (is the word "console" meant to be everywhere?) and it all seems to be one-by-one. What's the easiest way of importing all the rules attached to a security group?
b

brave-planet-10645

03/09/2021, 8:20 AM
Hi Ben, No I don't think the word console is supposed to be all over the place. I'll raise an issue for that. In answer to your question, you can use the import CLI command with a list of resources to import, so you could get the list of rules from the AWS CLI and then pipe that through to the pulumi import command
e

enough-leather-70274

03/09/2021, 8:44 AM
Thanks @brave-planet-10645 - is there an example anywhere for this? https://www.pulumi.com/docs/reference/cli/pulumi_import/ says the the CLI is single resource only and that for multiples you have to use a JSON file in a specific format. The problem is individual security group rules don't have an arn AFAIK and the output of
aws ec2 describe-security-groups
doesn't look anything like the JSON format
pulumi import
is expecting.
TBH, the API feels a little underbaked. I'd expect when I import a security group it'd also import all the rules attached to that group.
b

brave-planet-10645

03/09/2021, 8:53 AM
So you will have to parse the output from the AWS CLI to get it into a format that you'd want. It might not be possible to do it in one step, but it'll still be a lot quicker than doing it one at a time
e

enough-leather-70274

03/09/2021, 8:59 AM
OK - yeah that's less than ideal. What's the best way to submit this as a feature request Piers?
b

brave-planet-10645

03/09/2021, 9:03 AM
You can always raise an issue in the AWS provider repo: https://github.com/pulumi/pulumi-aws
👍 1