Package com.pulumi.aws.vpc
Class SecurityGroupIngressRule
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.vpc.SecurityGroupIngressRule
-
public class SecurityGroupIngressRule extends com.pulumi.resources.CustomResourceManages an inbound (ingress) rule for a security group. When specifying an inbound rule for your security group in a VPC, the configuration must include a source for the traffic. > **NOTE:** Using `aws.vpc.SecurityGroupEgressRule` and `aws.vpc.SecurityGroupIngressRule` resources is the current best practice. Avoid using the `aws.ec2.SecurityGroupRule` resource and the `ingress` and `egress` arguments of the `aws.ec2.SecurityGroup` resource for configuring in-line rules, as they struggle with managing multiple CIDR blocks, and tags and descriptions due to the historical lack of unique IDs. > **WARNING:** You should not use the `aws.vpc.SecurityGroupEgressRule` and `aws.vpc.SecurityGroupIngressRule` resources in conjunction with the `aws.ec2.SecurityGroup` resource with _in-line rules_ (using the `ingress` and `egress` arguments of `aws.ec2.SecurityGroup`) or the `aws.ec2.SecurityGroupRule` resource. Doing so may cause rule conflicts, perpetual differences, and result in rules being overwritten. ## Example Usage
## Import ### Identity Schema #### Required * `id` - (String) ID of the security group rule. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. Using `pulumi import`, import security group ingress rules using the `securityGroupRuleId`. For example: ```sh $ pulumi import aws:vpc/securityGroupIngressRule:SecurityGroupIngressRule example sgr-02108b27edd666983 ```package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.SecurityGroup; import com.pulumi.aws.ec2.SecurityGroupArgs; import com.pulumi.aws.vpc.SecurityGroupIngressRule; import com.pulumi.aws.vpc.SecurityGroupIngressRuleArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var example = new SecurityGroup("example", SecurityGroupArgs.builder() .name("example") .description("example") .vpcId(main.id()) .tags(Map.of("Name", "example")) .build()); var exampleSecurityGroupIngressRule = new SecurityGroupIngressRule("exampleSecurityGroupIngressRule", SecurityGroupIngressRuleArgs.builder() .securityGroupId(example.id()) .cidrIpv4("10.0.0.0/8") .fromPort(80) .ipProtocol("tcp") .toPort(80) .build()); } }
-
-
Constructor Summary
Constructors Constructor Description SecurityGroupIngressRule(java.lang.String name)SecurityGroupIngressRule(java.lang.String name, SecurityGroupIngressRuleArgs args)SecurityGroupIngressRule(java.lang.String name, SecurityGroupIngressRuleArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>arn()com.pulumi.core.Output<java.util.Optional<java.lang.String>>cidrIpv4()com.pulumi.core.Output<java.util.Optional<java.lang.String>>cidrIpv6()com.pulumi.core.Output<java.util.Optional<java.lang.String>>description()com.pulumi.core.Output<java.util.Optional<java.lang.Integer>>fromPort()static SecurityGroupIngressRuleget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, SecurityGroupIngressRuleState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.lang.String>ipProtocol()com.pulumi.core.Output<java.util.Optional<java.lang.String>>prefixListId()com.pulumi.core.Output<java.util.Optional<java.lang.String>>referencedSecurityGroupId()com.pulumi.core.Output<java.lang.String>region()com.pulumi.core.Output<java.lang.String>securityGroupId()com.pulumi.core.Output<java.lang.String>securityGroupRuleId()com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>>tags()com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>>tagsAll()com.pulumi.core.Output<java.util.Optional<java.lang.Integer>>toPort()
-
-
-
Constructor Detail
-
SecurityGroupIngressRule
public SecurityGroupIngressRule(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
SecurityGroupIngressRule
public SecurityGroupIngressRule(java.lang.String name, SecurityGroupIngressRuleArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
SecurityGroupIngressRule
public SecurityGroupIngressRule(java.lang.String name, SecurityGroupIngressRuleArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
arn
public com.pulumi.core.Output<java.lang.String> arn()
- Returns:
- ARN of the security group rule.
-
cidrIpv4
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> cidrIpv4()
- Returns:
- Source IPv4 CIDR range.
-
cidrIpv6
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> cidrIpv6()
- Returns:
- Source IPv6 CIDR range.
-
description
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> description()
- Returns:
- Security group rule description.
-
fromPort
public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> fromPort()
- Returns:
- Start of port range for the TCP and UDP protocols, or an ICMP/ICMPv6 type.
-
ipProtocol
public com.pulumi.core.Output<java.lang.String> ipProtocol()
- Returns:
- IP protocol name or number. Use `-1` to specify all protocols. Note that if `ipProtocol` is set to `-1`, it translates to all protocols, all port ranges, and `fromPort` and `toPort` values should not be defined.
-
prefixListId
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> prefixListId()
- Returns:
- ID of the source prefix list.
-
referencedSecurityGroupId
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> referencedSecurityGroupId()
- Returns:
- Source security group that is referenced in the rule.
-
region
public com.pulumi.core.Output<java.lang.String> region()
- Returns:
- Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
-
securityGroupId
public com.pulumi.core.Output<java.lang.String> securityGroupId()
- Returns:
- ID of the security group.
-
securityGroupRuleId
public com.pulumi.core.Output<java.lang.String> securityGroupRuleId()
- Returns:
- ID of the security group rule.
-
tags
public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>> tags()
- Returns:
- Map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
-
tagsAll
public com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>> tagsAll()
- Returns:
- Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
-
toPort
public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> toPort()
- Returns:
- End of port range for the TCP and UDP protocols, or an ICMP/ICMPv6 code. > **Note** Although `cidrIpv4`, `cidrIpv6`, `prefixListId`, and `referencedSecurityGroupId` are all marked as optional, you *must* provide one of them in order to configure the destination of the traffic. The `fromPort` and `toPort` arguments are required unless `ipProtocol` is set to `-1` or `icmpv6`.
-
get
public static SecurityGroupIngressRule get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable SecurityGroupIngressRuleState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-