github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/getSecurityGroups.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package ec2 5 6 import ( 7 "context" 8 "reflect" 9 10 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 11 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 ) 13 14 // Use this data source to get IDs and VPC membership of Security Groups that are created outside this provider. 15 // 16 // ## Example Usage 17 // 18 // <!--Start PulumiCodeChooser --> 19 // ```go 20 // package main 21 // 22 // import ( 23 // 24 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 25 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 26 // 27 // ) 28 // 29 // func main() { 30 // pulumi.Run(func(ctx *pulumi.Context) error { 31 // _, err := ec2.GetSecurityGroups(ctx, &ec2.GetSecurityGroupsArgs{ 32 // Tags: map[string]interface{}{ 33 // "Application": "k8s", 34 // "Environment": "dev", 35 // }, 36 // }, nil) 37 // if err != nil { 38 // return err 39 // } 40 // return nil 41 // }) 42 // } 43 // 44 // ``` 45 // <!--End PulumiCodeChooser --> 46 // 47 // <!--Start PulumiCodeChooser --> 48 // ```go 49 // package main 50 // 51 // import ( 52 // 53 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 54 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 55 // 56 // ) 57 // func main() { 58 // pulumi.Run(func(ctx *pulumi.Context) error { 59 // _, err := ec2.GetSecurityGroups(ctx, &ec2.GetSecurityGroupsArgs{ 60 // Filters: []ec2.GetSecurityGroupsFilter{ 61 // { 62 // Name: "group-name", 63 // Values: []string{ 64 // "*nodes*", 65 // }, 66 // }, 67 // { 68 // Name: "vpc-id", 69 // Values: interface{}{ 70 // vpcId, 71 // }, 72 // }, 73 // }, 74 // }, nil); 75 // if err != nil { 76 // return err 77 // } 78 // return nil 79 // }) 80 // } 81 // ``` 82 // <!--End PulumiCodeChooser --> 83 func GetSecurityGroups(ctx *pulumi.Context, args *GetSecurityGroupsArgs, opts ...pulumi.InvokeOption) (*GetSecurityGroupsResult, error) { 84 opts = internal.PkgInvokeDefaultOpts(opts) 85 var rv GetSecurityGroupsResult 86 err := ctx.Invoke("aws:ec2/getSecurityGroups:getSecurityGroups", args, &rv, opts...) 87 if err != nil { 88 return nil, err 89 } 90 return &rv, nil 91 } 92 93 // A collection of arguments for invoking getSecurityGroups. 94 type GetSecurityGroupsArgs struct { 95 // One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-security-groups in the AWS CLI reference][1]. 96 Filters []GetSecurityGroupsFilter `pulumi:"filters"` 97 // Map of tags, each pair of which must exactly match for desired security groups. 98 Tags map[string]string `pulumi:"tags"` 99 } 100 101 // A collection of values returned by getSecurityGroups. 102 type GetSecurityGroupsResult struct { 103 // ARNs of the matched security groups. 104 Arns []string `pulumi:"arns"` 105 Filters []GetSecurityGroupsFilter `pulumi:"filters"` 106 // The provider-assigned unique ID for this managed resource. 107 Id string `pulumi:"id"` 108 // IDs of the matches security groups. 109 Ids []string `pulumi:"ids"` 110 Tags map[string]string `pulumi:"tags"` 111 // VPC IDs of the matched security groups. The data source's tag or filter *will span VPCs* unless the `vpc-id` filter is also used. 112 VpcIds []string `pulumi:"vpcIds"` 113 } 114 115 func GetSecurityGroupsOutput(ctx *pulumi.Context, args GetSecurityGroupsOutputArgs, opts ...pulumi.InvokeOption) GetSecurityGroupsResultOutput { 116 return pulumi.ToOutputWithContext(context.Background(), args). 117 ApplyT(func(v interface{}) (GetSecurityGroupsResult, error) { 118 args := v.(GetSecurityGroupsArgs) 119 r, err := GetSecurityGroups(ctx, &args, opts...) 120 var s GetSecurityGroupsResult 121 if r != nil { 122 s = *r 123 } 124 return s, err 125 }).(GetSecurityGroupsResultOutput) 126 } 127 128 // A collection of arguments for invoking getSecurityGroups. 129 type GetSecurityGroupsOutputArgs struct { 130 // One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-security-groups in the AWS CLI reference][1]. 131 Filters GetSecurityGroupsFilterArrayInput `pulumi:"filters"` 132 // Map of tags, each pair of which must exactly match for desired security groups. 133 Tags pulumi.StringMapInput `pulumi:"tags"` 134 } 135 136 func (GetSecurityGroupsOutputArgs) ElementType() reflect.Type { 137 return reflect.TypeOf((*GetSecurityGroupsArgs)(nil)).Elem() 138 } 139 140 // A collection of values returned by getSecurityGroups. 141 type GetSecurityGroupsResultOutput struct{ *pulumi.OutputState } 142 143 func (GetSecurityGroupsResultOutput) ElementType() reflect.Type { 144 return reflect.TypeOf((*GetSecurityGroupsResult)(nil)).Elem() 145 } 146 147 func (o GetSecurityGroupsResultOutput) ToGetSecurityGroupsResultOutput() GetSecurityGroupsResultOutput { 148 return o 149 } 150 151 func (o GetSecurityGroupsResultOutput) ToGetSecurityGroupsResultOutputWithContext(ctx context.Context) GetSecurityGroupsResultOutput { 152 return o 153 } 154 155 // ARNs of the matched security groups. 156 func (o GetSecurityGroupsResultOutput) Arns() pulumi.StringArrayOutput { 157 return o.ApplyT(func(v GetSecurityGroupsResult) []string { return v.Arns }).(pulumi.StringArrayOutput) 158 } 159 160 func (o GetSecurityGroupsResultOutput) Filters() GetSecurityGroupsFilterArrayOutput { 161 return o.ApplyT(func(v GetSecurityGroupsResult) []GetSecurityGroupsFilter { return v.Filters }).(GetSecurityGroupsFilterArrayOutput) 162 } 163 164 // The provider-assigned unique ID for this managed resource. 165 func (o GetSecurityGroupsResultOutput) Id() pulumi.StringOutput { 166 return o.ApplyT(func(v GetSecurityGroupsResult) string { return v.Id }).(pulumi.StringOutput) 167 } 168 169 // IDs of the matches security groups. 170 func (o GetSecurityGroupsResultOutput) Ids() pulumi.StringArrayOutput { 171 return o.ApplyT(func(v GetSecurityGroupsResult) []string { return v.Ids }).(pulumi.StringArrayOutput) 172 } 173 174 func (o GetSecurityGroupsResultOutput) Tags() pulumi.StringMapOutput { 175 return o.ApplyT(func(v GetSecurityGroupsResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput) 176 } 177 178 // VPC IDs of the matched security groups. The data source's tag or filter *will span VPCs* unless the `vpc-id` filter is also used. 179 func (o GetSecurityGroupsResultOutput) VpcIds() pulumi.StringArrayOutput { 180 return o.ApplyT(func(v GetSecurityGroupsResult) []string { return v.VpcIds }).(pulumi.StringArrayOutput) 181 } 182 183 func init() { 184 pulumi.RegisterOutputType(GetSecurityGroupsResultOutput{}) 185 }