github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/securityGroupRule.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 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Provides a security group rule resource. Represents a single `ingress` or 16 // `egress` group rule, which can be added to external Security Groups. 17 // 18 // > **NOTE on Security Groups and Security Group Rules:** This provider currently provides a Security Group resource with `ingress` and `egress` rules defined in-line and a Security Group Rule resource which manages one or more `ingress` or 19 // `egress` rules. Both of these resource were added before AWS assigned a [security group rule unique ID](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-rules.html), and they do not work well in all scenarios using the`description` and `tags` attributes, which rely on the unique ID. 20 // The `vpc.SecurityGroupEgressRule` and `vpc.SecurityGroupIngressRule` resources have been added to address these limitations and should be used for all new security group rules. 21 // You should not use the `vpc.SecurityGroupEgressRule` and `vpc.SecurityGroupIngressRule` resources in conjunction with an `ec2.SecurityGroup` resource with in-line rules or with `ec2.SecurityGroupRule` resources defined for the same Security Group, as rule conflicts may occur and rules will be overwritten. 22 // 23 // > **NOTE:** Setting `protocol = "all"` or `protocol = -1` with `fromPort` and `toPort` will result in the EC2 API creating a security group rule with all ports open. This API behavior cannot be controlled by this provider and may generate warnings in the future. 24 // 25 // > **NOTE:** Referencing Security Groups across VPC peering has certain restrictions. More information is available in the [VPC Peering User Guide](https://docs.aws.amazon.com/vpc/latest/peering/vpc-peering-security-groups.html). 26 // 27 // ## Example Usage 28 // 29 // # Basic usage 30 // 31 // <!--Start PulumiCodeChooser --> 32 // ```go 33 // package main 34 // 35 // import ( 36 // 37 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 38 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 39 // 40 // ) 41 // 42 // func main() { 43 // pulumi.Run(func(ctx *pulumi.Context) error { 44 // _, err := ec2.NewSecurityGroupRule(ctx, "example", &ec2.SecurityGroupRuleArgs{ 45 // Type: pulumi.String("ingress"), 46 // FromPort: pulumi.Int(0), 47 // ToPort: pulumi.Int(65535), 48 // Protocol: pulumi.String(ec2.ProtocolTypeTCP), 49 // CidrBlocks: pulumi.StringArray{ 50 // exampleAwsVpc.CidrBlock, 51 // }, 52 // Ipv6CidrBlocks: pulumi.StringArray{ 53 // exampleAwsVpc.Ipv6CidrBlock, 54 // }, 55 // SecurityGroupId: pulumi.String("sg-123456"), 56 // }) 57 // if err != nil { 58 // return err 59 // } 60 // return nil 61 // }) 62 // } 63 // 64 // ``` 65 // <!--End PulumiCodeChooser --> 66 // 67 // ### Usage With Prefix List IDs 68 // 69 // Prefix Lists are either managed by AWS internally, or created by the customer using a 70 // Managed Prefix List resource. Prefix Lists provided by 71 // AWS are associated with a prefix list name, or service name, that is linked to a specific region. 72 // 73 // Prefix list IDs are exported on VPC Endpoints, so you can use this format: 74 // 75 // <!--Start PulumiCodeChooser --> 76 // ```go 77 // package main 78 // 79 // import ( 80 // 81 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 82 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 83 // 84 // ) 85 // 86 // func main() { 87 // pulumi.Run(func(ctx *pulumi.Context) error { 88 // // ... 89 // myEndpoint, err := ec2.NewVpcEndpoint(ctx, "my_endpoint", nil) 90 // if err != nil { 91 // return err 92 // } 93 // _, err = ec2.NewSecurityGroupRule(ctx, "allow_all", &ec2.SecurityGroupRuleArgs{ 94 // Type: pulumi.String("egress"), 95 // ToPort: pulumi.Int(0), 96 // Protocol: pulumi.String("-1"), 97 // PrefixListIds: pulumi.StringArray{ 98 // myEndpoint.PrefixListId, 99 // }, 100 // FromPort: pulumi.Int(0), 101 // SecurityGroupId: pulumi.String("sg-123456"), 102 // }) 103 // if err != nil { 104 // return err 105 // } 106 // return nil 107 // }) 108 // } 109 // 110 // ``` 111 // <!--End PulumiCodeChooser --> 112 // 113 // You can also find a specific Prefix List using the `ec2.getPrefixList` 114 // or `ec2ManagedPrefixList` data sources: 115 // 116 // <!--Start PulumiCodeChooser --> 117 // ```go 118 // package main 119 // 120 // import ( 121 // 122 // "fmt" 123 // 124 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws" 125 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 126 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 127 // 128 // ) 129 // 130 // func main() { 131 // pulumi.Run(func(ctx *pulumi.Context) error { 132 // current, err := aws.GetRegion(ctx, nil, nil) 133 // if err != nil { 134 // return err 135 // } 136 // s3, err := ec2.GetPrefixList(ctx, &ec2.GetPrefixListArgs{ 137 // Name: pulumi.StringRef(fmt.Sprintf("com.amazonaws.%v.s3", current.Name)), 138 // }, nil) 139 // if err != nil { 140 // return err 141 // } 142 // _, err = ec2.NewSecurityGroupRule(ctx, "s3_gateway_egress", &ec2.SecurityGroupRuleArgs{ 143 // Description: pulumi.String("S3 Gateway Egress"), 144 // Type: pulumi.String("egress"), 145 // SecurityGroupId: pulumi.String("sg-123456"), 146 // FromPort: pulumi.Int(443), 147 // ToPort: pulumi.Int(443), 148 // Protocol: pulumi.String(ec2.ProtocolTypeTCP), 149 // PrefixListIds: pulumi.StringArray{ 150 // pulumi.String(s3.Id), 151 // }, 152 // }) 153 // if err != nil { 154 // return err 155 // } 156 // return nil 157 // }) 158 // } 159 // 160 // ``` 161 // <!--End PulumiCodeChooser --> 162 // 163 // ## Import 164 // 165 // Import a rule with various IPv4 and IPv6 source CIDR blocks: 166 // 167 // Import a rule, applicable to all ports, with a protocol other than TCP/UDP/ICMP/ICMPV6/ALL, e.g., Multicast Transport Protocol (MTP), using the IANA protocol number. For example: 92. 168 // 169 // Import a default any/any egress rule to 0.0.0.0/0: 170 // 171 // Import an egress rule with a prefix list ID destination: 172 // 173 // Import a rule applicable to all protocols and ports with a security group source: 174 // 175 // Import a rule that has itself and an IPv6 CIDR block as sources: 176 // 177 // __Using `pulumi import` to import__ Security Group Rules using the `security_group_id`, `type`, `protocol`, `from_port`, `to_port`, and source(s)/destination(s) (such as a `cidr_block`) separated by underscores (`_`). All parts are required. For example: 178 // 179 // __NOTE:__ Not all rule permissions (e.g., not all of a rule's CIDR blocks) need to be imported for this provider to manage rule permissions. However, importing some of a rule's permissions but not others, and then making changes to the rule will result in the creation of an additional rule to capture the updated permissions. Rule permissions that were not imported are left intact in the original rule. 180 // 181 // Import an ingress rule in security group `sg-6e616f6d69` for TCP port 8000 with an IPv4 destination CIDR of `10.0.3.0/24`: 182 // 183 // ```sh 184 // $ pulumi import aws:ec2/securityGroupRule:SecurityGroupRule ingress sg-6e616f6d69_ingress_tcp_8000_8000_10.0.3.0/24 185 // ``` 186 // Import a rule with various IPv4 and IPv6 source CIDR blocks: 187 // 188 // ```sh 189 // $ pulumi import aws:ec2/securityGroupRule:SecurityGroupRule ingress sg-4973616163_ingress_tcp_100_121_10.1.0.0/16_2001:db8::/48_10.2.0.0/16_2002:db8::/48 190 // ``` 191 // Import a rule, applicable to all ports, with a protocol other than TCP/UDP/ICMP/ICMPV6/ALL, e.g., Multicast Transport Protocol (MTP), using the IANA protocol number. For example: 92. 192 // 193 // ```sh 194 // $ pulumi import aws:ec2/securityGroupRule:SecurityGroupRule ingress sg-6777656e646f6c796e_ingress_92_0_65536_10.0.3.0/24_10.0.4.0/24 195 // ``` 196 // Import a default any/any egress rule to 0.0.0.0/0: 197 // 198 // ```sh 199 // $ pulumi import aws:ec2/securityGroupRule:SecurityGroupRule default_egress sg-6777656e646f6c796e_egress_all_0_0_0.0.0.0/0 200 // ``` 201 // Import an egress rule with a prefix list ID destination: 202 // 203 // ```sh 204 // $ pulumi import aws:ec2/securityGroupRule:SecurityGroupRule egress sg-62726f6479_egress_tcp_8000_8000_pl-6469726b 205 // ``` 206 // Import a rule applicable to all protocols and ports with a security group source: 207 // 208 // ```sh 209 // $ pulumi import aws:ec2/securityGroupRule:SecurityGroupRule ingress_rule sg-7472697374616e_ingress_all_0_65536_sg-6176657279 210 // ``` 211 // Import a rule that has itself and an IPv6 CIDR block as sources: 212 // 213 // ```sh 214 // $ pulumi import aws:ec2/securityGroupRule:SecurityGroupRule rule_name sg-656c65616e6f72_ingress_tcp_80_80_self_2001:db8::/48 215 // ``` 216 type SecurityGroupRule struct { 217 pulumi.CustomResourceState 218 219 // List of CIDR blocks. Cannot be specified with `sourceSecurityGroupId` or `self`. 220 CidrBlocks pulumi.StringArrayOutput `pulumi:"cidrBlocks"` 221 // Description of the rule. 222 Description pulumi.StringPtrOutput `pulumi:"description"` 223 // Start port (or ICMP type number if protocol is "icmp" or "icmpv6"). 224 FromPort pulumi.IntOutput `pulumi:"fromPort"` 225 // List of IPv6 CIDR blocks. Cannot be specified with `sourceSecurityGroupId` or `self`. 226 Ipv6CidrBlocks pulumi.StringArrayOutput `pulumi:"ipv6CidrBlocks"` 227 // List of Prefix List IDs. 228 PrefixListIds pulumi.StringArrayOutput `pulumi:"prefixListIds"` 229 // Protocol. If not icmp, icmpv6, tcp, udp, or all use the [protocol number](https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml) 230 Protocol pulumi.StringOutput `pulumi:"protocol"` 231 // Security group to apply this rule to. 232 SecurityGroupId pulumi.StringOutput `pulumi:"securityGroupId"` 233 // If the `ec2.SecurityGroupRule` resource has a single source or destination then this is the AWS Security Group Rule resource ID. Otherwise it is empty. 234 SecurityGroupRuleId pulumi.StringOutput `pulumi:"securityGroupRuleId"` 235 // Whether the security group itself will be added as a source to this ingress rule. Cannot be specified with `cidrBlocks`, `ipv6CidrBlocks`, or `sourceSecurityGroupId`. 236 Self pulumi.BoolPtrOutput `pulumi:"self"` 237 // Security group id to allow access to/from, depending on the `type`. Cannot be specified with `cidrBlocks`, `ipv6CidrBlocks`, or `self`. 238 SourceSecurityGroupId pulumi.StringOutput `pulumi:"sourceSecurityGroupId"` 239 // End port (or ICMP code if protocol is "icmp"). 240 ToPort pulumi.IntOutput `pulumi:"toPort"` 241 // Type of rule being created. Valid options are `ingress` (inbound) 242 // or `egress` (outbound). 243 // 244 // The following arguments are optional: 245 // 246 // > **Note** Although `cidrBlocks`, `ipv6CidrBlocks`, `prefixListIds`, and `sourceSecurityGroupId` are all marked as optional, you _must_ provide one of them in order to configure the source of the traffic. 247 Type pulumi.StringOutput `pulumi:"type"` 248 } 249 250 // NewSecurityGroupRule registers a new resource with the given unique name, arguments, and options. 251 func NewSecurityGroupRule(ctx *pulumi.Context, 252 name string, args *SecurityGroupRuleArgs, opts ...pulumi.ResourceOption) (*SecurityGroupRule, error) { 253 if args == nil { 254 return nil, errors.New("missing one or more required arguments") 255 } 256 257 if args.FromPort == nil { 258 return nil, errors.New("invalid value for required argument 'FromPort'") 259 } 260 if args.Protocol == nil { 261 return nil, errors.New("invalid value for required argument 'Protocol'") 262 } 263 if args.SecurityGroupId == nil { 264 return nil, errors.New("invalid value for required argument 'SecurityGroupId'") 265 } 266 if args.ToPort == nil { 267 return nil, errors.New("invalid value for required argument 'ToPort'") 268 } 269 if args.Type == nil { 270 return nil, errors.New("invalid value for required argument 'Type'") 271 } 272 opts = internal.PkgResourceDefaultOpts(opts) 273 var resource SecurityGroupRule 274 err := ctx.RegisterResource("aws:ec2/securityGroupRule:SecurityGroupRule", name, args, &resource, opts...) 275 if err != nil { 276 return nil, err 277 } 278 return &resource, nil 279 } 280 281 // GetSecurityGroupRule gets an existing SecurityGroupRule resource's state with the given name, ID, and optional 282 // state properties that are used to uniquely qualify the lookup (nil if not required). 283 func GetSecurityGroupRule(ctx *pulumi.Context, 284 name string, id pulumi.IDInput, state *SecurityGroupRuleState, opts ...pulumi.ResourceOption) (*SecurityGroupRule, error) { 285 var resource SecurityGroupRule 286 err := ctx.ReadResource("aws:ec2/securityGroupRule:SecurityGroupRule", name, id, state, &resource, opts...) 287 if err != nil { 288 return nil, err 289 } 290 return &resource, nil 291 } 292 293 // Input properties used for looking up and filtering SecurityGroupRule resources. 294 type securityGroupRuleState struct { 295 // List of CIDR blocks. Cannot be specified with `sourceSecurityGroupId` or `self`. 296 CidrBlocks []string `pulumi:"cidrBlocks"` 297 // Description of the rule. 298 Description *string `pulumi:"description"` 299 // Start port (or ICMP type number if protocol is "icmp" or "icmpv6"). 300 FromPort *int `pulumi:"fromPort"` 301 // List of IPv6 CIDR blocks. Cannot be specified with `sourceSecurityGroupId` or `self`. 302 Ipv6CidrBlocks []string `pulumi:"ipv6CidrBlocks"` 303 // List of Prefix List IDs. 304 PrefixListIds []string `pulumi:"prefixListIds"` 305 // Protocol. If not icmp, icmpv6, tcp, udp, or all use the [protocol number](https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml) 306 Protocol *string `pulumi:"protocol"` 307 // Security group to apply this rule to. 308 SecurityGroupId *string `pulumi:"securityGroupId"` 309 // If the `ec2.SecurityGroupRule` resource has a single source or destination then this is the AWS Security Group Rule resource ID. Otherwise it is empty. 310 SecurityGroupRuleId *string `pulumi:"securityGroupRuleId"` 311 // Whether the security group itself will be added as a source to this ingress rule. Cannot be specified with `cidrBlocks`, `ipv6CidrBlocks`, or `sourceSecurityGroupId`. 312 Self *bool `pulumi:"self"` 313 // Security group id to allow access to/from, depending on the `type`. Cannot be specified with `cidrBlocks`, `ipv6CidrBlocks`, or `self`. 314 SourceSecurityGroupId *string `pulumi:"sourceSecurityGroupId"` 315 // End port (or ICMP code if protocol is "icmp"). 316 ToPort *int `pulumi:"toPort"` 317 // Type of rule being created. Valid options are `ingress` (inbound) 318 // or `egress` (outbound). 319 // 320 // The following arguments are optional: 321 // 322 // > **Note** Although `cidrBlocks`, `ipv6CidrBlocks`, `prefixListIds`, and `sourceSecurityGroupId` are all marked as optional, you _must_ provide one of them in order to configure the source of the traffic. 323 Type *string `pulumi:"type"` 324 } 325 326 type SecurityGroupRuleState struct { 327 // List of CIDR blocks. Cannot be specified with `sourceSecurityGroupId` or `self`. 328 CidrBlocks pulumi.StringArrayInput 329 // Description of the rule. 330 Description pulumi.StringPtrInput 331 // Start port (or ICMP type number if protocol is "icmp" or "icmpv6"). 332 FromPort pulumi.IntPtrInput 333 // List of IPv6 CIDR blocks. Cannot be specified with `sourceSecurityGroupId` or `self`. 334 Ipv6CidrBlocks pulumi.StringArrayInput 335 // List of Prefix List IDs. 336 PrefixListIds pulumi.StringArrayInput 337 // Protocol. If not icmp, icmpv6, tcp, udp, or all use the [protocol number](https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml) 338 Protocol pulumi.StringPtrInput 339 // Security group to apply this rule to. 340 SecurityGroupId pulumi.StringPtrInput 341 // If the `ec2.SecurityGroupRule` resource has a single source or destination then this is the AWS Security Group Rule resource ID. Otherwise it is empty. 342 SecurityGroupRuleId pulumi.StringPtrInput 343 // Whether the security group itself will be added as a source to this ingress rule. Cannot be specified with `cidrBlocks`, `ipv6CidrBlocks`, or `sourceSecurityGroupId`. 344 Self pulumi.BoolPtrInput 345 // Security group id to allow access to/from, depending on the `type`. Cannot be specified with `cidrBlocks`, `ipv6CidrBlocks`, or `self`. 346 SourceSecurityGroupId pulumi.StringPtrInput 347 // End port (or ICMP code if protocol is "icmp"). 348 ToPort pulumi.IntPtrInput 349 // Type of rule being created. Valid options are `ingress` (inbound) 350 // or `egress` (outbound). 351 // 352 // The following arguments are optional: 353 // 354 // > **Note** Although `cidrBlocks`, `ipv6CidrBlocks`, `prefixListIds`, and `sourceSecurityGroupId` are all marked as optional, you _must_ provide one of them in order to configure the source of the traffic. 355 Type pulumi.StringPtrInput 356 } 357 358 func (SecurityGroupRuleState) ElementType() reflect.Type { 359 return reflect.TypeOf((*securityGroupRuleState)(nil)).Elem() 360 } 361 362 type securityGroupRuleArgs struct { 363 // List of CIDR blocks. Cannot be specified with `sourceSecurityGroupId` or `self`. 364 CidrBlocks []string `pulumi:"cidrBlocks"` 365 // Description of the rule. 366 Description *string `pulumi:"description"` 367 // Start port (or ICMP type number if protocol is "icmp" or "icmpv6"). 368 FromPort int `pulumi:"fromPort"` 369 // List of IPv6 CIDR blocks. Cannot be specified with `sourceSecurityGroupId` or `self`. 370 Ipv6CidrBlocks []string `pulumi:"ipv6CidrBlocks"` 371 // List of Prefix List IDs. 372 PrefixListIds []string `pulumi:"prefixListIds"` 373 // Protocol. If not icmp, icmpv6, tcp, udp, or all use the [protocol number](https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml) 374 Protocol string `pulumi:"protocol"` 375 // Security group to apply this rule to. 376 SecurityGroupId string `pulumi:"securityGroupId"` 377 // Whether the security group itself will be added as a source to this ingress rule. Cannot be specified with `cidrBlocks`, `ipv6CidrBlocks`, or `sourceSecurityGroupId`. 378 Self *bool `pulumi:"self"` 379 // Security group id to allow access to/from, depending on the `type`. Cannot be specified with `cidrBlocks`, `ipv6CidrBlocks`, or `self`. 380 SourceSecurityGroupId *string `pulumi:"sourceSecurityGroupId"` 381 // End port (or ICMP code if protocol is "icmp"). 382 ToPort int `pulumi:"toPort"` 383 // Type of rule being created. Valid options are `ingress` (inbound) 384 // or `egress` (outbound). 385 // 386 // The following arguments are optional: 387 // 388 // > **Note** Although `cidrBlocks`, `ipv6CidrBlocks`, `prefixListIds`, and `sourceSecurityGroupId` are all marked as optional, you _must_ provide one of them in order to configure the source of the traffic. 389 Type string `pulumi:"type"` 390 } 391 392 // The set of arguments for constructing a SecurityGroupRule resource. 393 type SecurityGroupRuleArgs struct { 394 // List of CIDR blocks. Cannot be specified with `sourceSecurityGroupId` or `self`. 395 CidrBlocks pulumi.StringArrayInput 396 // Description of the rule. 397 Description pulumi.StringPtrInput 398 // Start port (or ICMP type number if protocol is "icmp" or "icmpv6"). 399 FromPort pulumi.IntInput 400 // List of IPv6 CIDR blocks. Cannot be specified with `sourceSecurityGroupId` or `self`. 401 Ipv6CidrBlocks pulumi.StringArrayInput 402 // List of Prefix List IDs. 403 PrefixListIds pulumi.StringArrayInput 404 // Protocol. If not icmp, icmpv6, tcp, udp, or all use the [protocol number](https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml) 405 Protocol pulumi.StringInput 406 // Security group to apply this rule to. 407 SecurityGroupId pulumi.StringInput 408 // Whether the security group itself will be added as a source to this ingress rule. Cannot be specified with `cidrBlocks`, `ipv6CidrBlocks`, or `sourceSecurityGroupId`. 409 Self pulumi.BoolPtrInput 410 // Security group id to allow access to/from, depending on the `type`. Cannot be specified with `cidrBlocks`, `ipv6CidrBlocks`, or `self`. 411 SourceSecurityGroupId pulumi.StringPtrInput 412 // End port (or ICMP code if protocol is "icmp"). 413 ToPort pulumi.IntInput 414 // Type of rule being created. Valid options are `ingress` (inbound) 415 // or `egress` (outbound). 416 // 417 // The following arguments are optional: 418 // 419 // > **Note** Although `cidrBlocks`, `ipv6CidrBlocks`, `prefixListIds`, and `sourceSecurityGroupId` are all marked as optional, you _must_ provide one of them in order to configure the source of the traffic. 420 Type pulumi.StringInput 421 } 422 423 func (SecurityGroupRuleArgs) ElementType() reflect.Type { 424 return reflect.TypeOf((*securityGroupRuleArgs)(nil)).Elem() 425 } 426 427 type SecurityGroupRuleInput interface { 428 pulumi.Input 429 430 ToSecurityGroupRuleOutput() SecurityGroupRuleOutput 431 ToSecurityGroupRuleOutputWithContext(ctx context.Context) SecurityGroupRuleOutput 432 } 433 434 func (*SecurityGroupRule) ElementType() reflect.Type { 435 return reflect.TypeOf((**SecurityGroupRule)(nil)).Elem() 436 } 437 438 func (i *SecurityGroupRule) ToSecurityGroupRuleOutput() SecurityGroupRuleOutput { 439 return i.ToSecurityGroupRuleOutputWithContext(context.Background()) 440 } 441 442 func (i *SecurityGroupRule) ToSecurityGroupRuleOutputWithContext(ctx context.Context) SecurityGroupRuleOutput { 443 return pulumi.ToOutputWithContext(ctx, i).(SecurityGroupRuleOutput) 444 } 445 446 // SecurityGroupRuleArrayInput is an input type that accepts SecurityGroupRuleArray and SecurityGroupRuleArrayOutput values. 447 // You can construct a concrete instance of `SecurityGroupRuleArrayInput` via: 448 // 449 // SecurityGroupRuleArray{ SecurityGroupRuleArgs{...} } 450 type SecurityGroupRuleArrayInput interface { 451 pulumi.Input 452 453 ToSecurityGroupRuleArrayOutput() SecurityGroupRuleArrayOutput 454 ToSecurityGroupRuleArrayOutputWithContext(context.Context) SecurityGroupRuleArrayOutput 455 } 456 457 type SecurityGroupRuleArray []SecurityGroupRuleInput 458 459 func (SecurityGroupRuleArray) ElementType() reflect.Type { 460 return reflect.TypeOf((*[]*SecurityGroupRule)(nil)).Elem() 461 } 462 463 func (i SecurityGroupRuleArray) ToSecurityGroupRuleArrayOutput() SecurityGroupRuleArrayOutput { 464 return i.ToSecurityGroupRuleArrayOutputWithContext(context.Background()) 465 } 466 467 func (i SecurityGroupRuleArray) ToSecurityGroupRuleArrayOutputWithContext(ctx context.Context) SecurityGroupRuleArrayOutput { 468 return pulumi.ToOutputWithContext(ctx, i).(SecurityGroupRuleArrayOutput) 469 } 470 471 // SecurityGroupRuleMapInput is an input type that accepts SecurityGroupRuleMap and SecurityGroupRuleMapOutput values. 472 // You can construct a concrete instance of `SecurityGroupRuleMapInput` via: 473 // 474 // SecurityGroupRuleMap{ "key": SecurityGroupRuleArgs{...} } 475 type SecurityGroupRuleMapInput interface { 476 pulumi.Input 477 478 ToSecurityGroupRuleMapOutput() SecurityGroupRuleMapOutput 479 ToSecurityGroupRuleMapOutputWithContext(context.Context) SecurityGroupRuleMapOutput 480 } 481 482 type SecurityGroupRuleMap map[string]SecurityGroupRuleInput 483 484 func (SecurityGroupRuleMap) ElementType() reflect.Type { 485 return reflect.TypeOf((*map[string]*SecurityGroupRule)(nil)).Elem() 486 } 487 488 func (i SecurityGroupRuleMap) ToSecurityGroupRuleMapOutput() SecurityGroupRuleMapOutput { 489 return i.ToSecurityGroupRuleMapOutputWithContext(context.Background()) 490 } 491 492 func (i SecurityGroupRuleMap) ToSecurityGroupRuleMapOutputWithContext(ctx context.Context) SecurityGroupRuleMapOutput { 493 return pulumi.ToOutputWithContext(ctx, i).(SecurityGroupRuleMapOutput) 494 } 495 496 type SecurityGroupRuleOutput struct{ *pulumi.OutputState } 497 498 func (SecurityGroupRuleOutput) ElementType() reflect.Type { 499 return reflect.TypeOf((**SecurityGroupRule)(nil)).Elem() 500 } 501 502 func (o SecurityGroupRuleOutput) ToSecurityGroupRuleOutput() SecurityGroupRuleOutput { 503 return o 504 } 505 506 func (o SecurityGroupRuleOutput) ToSecurityGroupRuleOutputWithContext(ctx context.Context) SecurityGroupRuleOutput { 507 return o 508 } 509 510 // List of CIDR blocks. Cannot be specified with `sourceSecurityGroupId` or `self`. 511 func (o SecurityGroupRuleOutput) CidrBlocks() pulumi.StringArrayOutput { 512 return o.ApplyT(func(v *SecurityGroupRule) pulumi.StringArrayOutput { return v.CidrBlocks }).(pulumi.StringArrayOutput) 513 } 514 515 // Description of the rule. 516 func (o SecurityGroupRuleOutput) Description() pulumi.StringPtrOutput { 517 return o.ApplyT(func(v *SecurityGroupRule) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput) 518 } 519 520 // Start port (or ICMP type number if protocol is "icmp" or "icmpv6"). 521 func (o SecurityGroupRuleOutput) FromPort() pulumi.IntOutput { 522 return o.ApplyT(func(v *SecurityGroupRule) pulumi.IntOutput { return v.FromPort }).(pulumi.IntOutput) 523 } 524 525 // List of IPv6 CIDR blocks. Cannot be specified with `sourceSecurityGroupId` or `self`. 526 func (o SecurityGroupRuleOutput) Ipv6CidrBlocks() pulumi.StringArrayOutput { 527 return o.ApplyT(func(v *SecurityGroupRule) pulumi.StringArrayOutput { return v.Ipv6CidrBlocks }).(pulumi.StringArrayOutput) 528 } 529 530 // List of Prefix List IDs. 531 func (o SecurityGroupRuleOutput) PrefixListIds() pulumi.StringArrayOutput { 532 return o.ApplyT(func(v *SecurityGroupRule) pulumi.StringArrayOutput { return v.PrefixListIds }).(pulumi.StringArrayOutput) 533 } 534 535 // Protocol. If not icmp, icmpv6, tcp, udp, or all use the [protocol number](https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml) 536 func (o SecurityGroupRuleOutput) Protocol() pulumi.StringOutput { 537 return o.ApplyT(func(v *SecurityGroupRule) pulumi.StringOutput { return v.Protocol }).(pulumi.StringOutput) 538 } 539 540 // Security group to apply this rule to. 541 func (o SecurityGroupRuleOutput) SecurityGroupId() pulumi.StringOutput { 542 return o.ApplyT(func(v *SecurityGroupRule) pulumi.StringOutput { return v.SecurityGroupId }).(pulumi.StringOutput) 543 } 544 545 // If the `ec2.SecurityGroupRule` resource has a single source or destination then this is the AWS Security Group Rule resource ID. Otherwise it is empty. 546 func (o SecurityGroupRuleOutput) SecurityGroupRuleId() pulumi.StringOutput { 547 return o.ApplyT(func(v *SecurityGroupRule) pulumi.StringOutput { return v.SecurityGroupRuleId }).(pulumi.StringOutput) 548 } 549 550 // Whether the security group itself will be added as a source to this ingress rule. Cannot be specified with `cidrBlocks`, `ipv6CidrBlocks`, or `sourceSecurityGroupId`. 551 func (o SecurityGroupRuleOutput) Self() pulumi.BoolPtrOutput { 552 return o.ApplyT(func(v *SecurityGroupRule) pulumi.BoolPtrOutput { return v.Self }).(pulumi.BoolPtrOutput) 553 } 554 555 // Security group id to allow access to/from, depending on the `type`. Cannot be specified with `cidrBlocks`, `ipv6CidrBlocks`, or `self`. 556 func (o SecurityGroupRuleOutput) SourceSecurityGroupId() pulumi.StringOutput { 557 return o.ApplyT(func(v *SecurityGroupRule) pulumi.StringOutput { return v.SourceSecurityGroupId }).(pulumi.StringOutput) 558 } 559 560 // End port (or ICMP code if protocol is "icmp"). 561 func (o SecurityGroupRuleOutput) ToPort() pulumi.IntOutput { 562 return o.ApplyT(func(v *SecurityGroupRule) pulumi.IntOutput { return v.ToPort }).(pulumi.IntOutput) 563 } 564 565 // Type of rule being created. Valid options are `ingress` (inbound) 566 // or `egress` (outbound). 567 // 568 // The following arguments are optional: 569 // 570 // > **Note** Although `cidrBlocks`, `ipv6CidrBlocks`, `prefixListIds`, and `sourceSecurityGroupId` are all marked as optional, you _must_ provide one of them in order to configure the source of the traffic. 571 func (o SecurityGroupRuleOutput) Type() pulumi.StringOutput { 572 return o.ApplyT(func(v *SecurityGroupRule) pulumi.StringOutput { return v.Type }).(pulumi.StringOutput) 573 } 574 575 type SecurityGroupRuleArrayOutput struct{ *pulumi.OutputState } 576 577 func (SecurityGroupRuleArrayOutput) ElementType() reflect.Type { 578 return reflect.TypeOf((*[]*SecurityGroupRule)(nil)).Elem() 579 } 580 581 func (o SecurityGroupRuleArrayOutput) ToSecurityGroupRuleArrayOutput() SecurityGroupRuleArrayOutput { 582 return o 583 } 584 585 func (o SecurityGroupRuleArrayOutput) ToSecurityGroupRuleArrayOutputWithContext(ctx context.Context) SecurityGroupRuleArrayOutput { 586 return o 587 } 588 589 func (o SecurityGroupRuleArrayOutput) Index(i pulumi.IntInput) SecurityGroupRuleOutput { 590 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *SecurityGroupRule { 591 return vs[0].([]*SecurityGroupRule)[vs[1].(int)] 592 }).(SecurityGroupRuleOutput) 593 } 594 595 type SecurityGroupRuleMapOutput struct{ *pulumi.OutputState } 596 597 func (SecurityGroupRuleMapOutput) ElementType() reflect.Type { 598 return reflect.TypeOf((*map[string]*SecurityGroupRule)(nil)).Elem() 599 } 600 601 func (o SecurityGroupRuleMapOutput) ToSecurityGroupRuleMapOutput() SecurityGroupRuleMapOutput { 602 return o 603 } 604 605 func (o SecurityGroupRuleMapOutput) ToSecurityGroupRuleMapOutputWithContext(ctx context.Context) SecurityGroupRuleMapOutput { 606 return o 607 } 608 609 func (o SecurityGroupRuleMapOutput) MapIndex(k pulumi.StringInput) SecurityGroupRuleOutput { 610 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *SecurityGroupRule { 611 return vs[0].(map[string]*SecurityGroupRule)[vs[1].(string)] 612 }).(SecurityGroupRuleOutput) 613 } 614 615 func init() { 616 pulumi.RegisterInputType(reflect.TypeOf((*SecurityGroupRuleInput)(nil)).Elem(), &SecurityGroupRule{}) 617 pulumi.RegisterInputType(reflect.TypeOf((*SecurityGroupRuleArrayInput)(nil)).Elem(), SecurityGroupRuleArray{}) 618 pulumi.RegisterInputType(reflect.TypeOf((*SecurityGroupRuleMapInput)(nil)).Elem(), SecurityGroupRuleMap{}) 619 pulumi.RegisterOutputType(SecurityGroupRuleOutput{}) 620 pulumi.RegisterOutputType(SecurityGroupRuleArrayOutput{}) 621 pulumi.RegisterOutputType(SecurityGroupRuleMapOutput{}) 622 }