github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2clientvpn/authorizationRule.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 ec2clientvpn
     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 authorization rules for AWS Client VPN endpoints. For more information on usage, please see the
    16  // [AWS Client VPN Administrator's Guide](https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/what-is.html).
    17  //
    18  // ## Example Usage
    19  //
    20  // <!--Start PulumiCodeChooser -->
    21  // ```go
    22  // package main
    23  //
    24  // import (
    25  //
    26  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2clientvpn"
    27  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    28  //
    29  // )
    30  //
    31  //	func main() {
    32  //		pulumi.Run(func(ctx *pulumi.Context) error {
    33  //			_, err := ec2clientvpn.NewAuthorizationRule(ctx, "example", &ec2clientvpn.AuthorizationRuleArgs{
    34  //				ClientVpnEndpointId: pulumi.Any(exampleAwsEc2ClientVpnEndpoint.Id),
    35  //				TargetNetworkCidr:   pulumi.Any(exampleAwsSubnet.CidrBlock),
    36  //				AuthorizeAllGroups:  pulumi.Bool(true),
    37  //			})
    38  //			if err != nil {
    39  //				return err
    40  //			}
    41  //			return nil
    42  //		})
    43  //	}
    44  //
    45  // ```
    46  // <!--End PulumiCodeChooser -->
    47  //
    48  // ## Import
    49  //
    50  // Using the endpoint ID, target network CIDR, and group name:
    51  //
    52  // __Using `pulumi import` to import__ AWS Client VPN authorization rules using the endpoint ID and target network CIDR. If there is a specific group name, include that also. All values are separated by a `,`. For example:
    53  //
    54  // Using the endpoint ID and target network CIDR:
    55  //
    56  // ```sh
    57  // $ pulumi import aws:ec2clientvpn/authorizationRule:AuthorizationRule example cvpn-endpoint-0ac3a1abbccddd666,10.1.0.0/24
    58  // ```
    59  // Using the endpoint ID, target network CIDR, and group name:
    60  //
    61  // ```sh
    62  // $ pulumi import aws:ec2clientvpn/authorizationRule:AuthorizationRule example cvpn-endpoint-0ac3a1abbccddd666,10.1.0.0/24,team-a
    63  // ```
    64  type AuthorizationRule struct {
    65  	pulumi.CustomResourceState
    66  
    67  	// The ID of the group to which the authorization rule grants access. One of `accessGroupId` or `authorizeAllGroups` must be set.
    68  	AccessGroupId pulumi.StringPtrOutput `pulumi:"accessGroupId"`
    69  	// Indicates whether the authorization rule grants access to all clients. One of `accessGroupId` or `authorizeAllGroups` must be set.
    70  	AuthorizeAllGroups pulumi.BoolPtrOutput `pulumi:"authorizeAllGroups"`
    71  	// The ID of the Client VPN endpoint.
    72  	ClientVpnEndpointId pulumi.StringOutput `pulumi:"clientVpnEndpointId"`
    73  	// A brief description of the authorization rule.
    74  	Description pulumi.StringPtrOutput `pulumi:"description"`
    75  	// The IPv4 address range, in CIDR notation, of the network to which the authorization rule applies.
    76  	TargetNetworkCidr pulumi.StringOutput `pulumi:"targetNetworkCidr"`
    77  }
    78  
    79  // NewAuthorizationRule registers a new resource with the given unique name, arguments, and options.
    80  func NewAuthorizationRule(ctx *pulumi.Context,
    81  	name string, args *AuthorizationRuleArgs, opts ...pulumi.ResourceOption) (*AuthorizationRule, error) {
    82  	if args == nil {
    83  		return nil, errors.New("missing one or more required arguments")
    84  	}
    85  
    86  	if args.ClientVpnEndpointId == nil {
    87  		return nil, errors.New("invalid value for required argument 'ClientVpnEndpointId'")
    88  	}
    89  	if args.TargetNetworkCidr == nil {
    90  		return nil, errors.New("invalid value for required argument 'TargetNetworkCidr'")
    91  	}
    92  	opts = internal.PkgResourceDefaultOpts(opts)
    93  	var resource AuthorizationRule
    94  	err := ctx.RegisterResource("aws:ec2clientvpn/authorizationRule:AuthorizationRule", name, args, &resource, opts...)
    95  	if err != nil {
    96  		return nil, err
    97  	}
    98  	return &resource, nil
    99  }
   100  
   101  // GetAuthorizationRule gets an existing AuthorizationRule resource's state with the given name, ID, and optional
   102  // state properties that are used to uniquely qualify the lookup (nil if not required).
   103  func GetAuthorizationRule(ctx *pulumi.Context,
   104  	name string, id pulumi.IDInput, state *AuthorizationRuleState, opts ...pulumi.ResourceOption) (*AuthorizationRule, error) {
   105  	var resource AuthorizationRule
   106  	err := ctx.ReadResource("aws:ec2clientvpn/authorizationRule:AuthorizationRule", name, id, state, &resource, opts...)
   107  	if err != nil {
   108  		return nil, err
   109  	}
   110  	return &resource, nil
   111  }
   112  
   113  // Input properties used for looking up and filtering AuthorizationRule resources.
   114  type authorizationRuleState struct {
   115  	// The ID of the group to which the authorization rule grants access. One of `accessGroupId` or `authorizeAllGroups` must be set.
   116  	AccessGroupId *string `pulumi:"accessGroupId"`
   117  	// Indicates whether the authorization rule grants access to all clients. One of `accessGroupId` or `authorizeAllGroups` must be set.
   118  	AuthorizeAllGroups *bool `pulumi:"authorizeAllGroups"`
   119  	// The ID of the Client VPN endpoint.
   120  	ClientVpnEndpointId *string `pulumi:"clientVpnEndpointId"`
   121  	// A brief description of the authorization rule.
   122  	Description *string `pulumi:"description"`
   123  	// The IPv4 address range, in CIDR notation, of the network to which the authorization rule applies.
   124  	TargetNetworkCidr *string `pulumi:"targetNetworkCidr"`
   125  }
   126  
   127  type AuthorizationRuleState struct {
   128  	// The ID of the group to which the authorization rule grants access. One of `accessGroupId` or `authorizeAllGroups` must be set.
   129  	AccessGroupId pulumi.StringPtrInput
   130  	// Indicates whether the authorization rule grants access to all clients. One of `accessGroupId` or `authorizeAllGroups` must be set.
   131  	AuthorizeAllGroups pulumi.BoolPtrInput
   132  	// The ID of the Client VPN endpoint.
   133  	ClientVpnEndpointId pulumi.StringPtrInput
   134  	// A brief description of the authorization rule.
   135  	Description pulumi.StringPtrInput
   136  	// The IPv4 address range, in CIDR notation, of the network to which the authorization rule applies.
   137  	TargetNetworkCidr pulumi.StringPtrInput
   138  }
   139  
   140  func (AuthorizationRuleState) ElementType() reflect.Type {
   141  	return reflect.TypeOf((*authorizationRuleState)(nil)).Elem()
   142  }
   143  
   144  type authorizationRuleArgs struct {
   145  	// The ID of the group to which the authorization rule grants access. One of `accessGroupId` or `authorizeAllGroups` must be set.
   146  	AccessGroupId *string `pulumi:"accessGroupId"`
   147  	// Indicates whether the authorization rule grants access to all clients. One of `accessGroupId` or `authorizeAllGroups` must be set.
   148  	AuthorizeAllGroups *bool `pulumi:"authorizeAllGroups"`
   149  	// The ID of the Client VPN endpoint.
   150  	ClientVpnEndpointId string `pulumi:"clientVpnEndpointId"`
   151  	// A brief description of the authorization rule.
   152  	Description *string `pulumi:"description"`
   153  	// The IPv4 address range, in CIDR notation, of the network to which the authorization rule applies.
   154  	TargetNetworkCidr string `pulumi:"targetNetworkCidr"`
   155  }
   156  
   157  // The set of arguments for constructing a AuthorizationRule resource.
   158  type AuthorizationRuleArgs struct {
   159  	// The ID of the group to which the authorization rule grants access. One of `accessGroupId` or `authorizeAllGroups` must be set.
   160  	AccessGroupId pulumi.StringPtrInput
   161  	// Indicates whether the authorization rule grants access to all clients. One of `accessGroupId` or `authorizeAllGroups` must be set.
   162  	AuthorizeAllGroups pulumi.BoolPtrInput
   163  	// The ID of the Client VPN endpoint.
   164  	ClientVpnEndpointId pulumi.StringInput
   165  	// A brief description of the authorization rule.
   166  	Description pulumi.StringPtrInput
   167  	// The IPv4 address range, in CIDR notation, of the network to which the authorization rule applies.
   168  	TargetNetworkCidr pulumi.StringInput
   169  }
   170  
   171  func (AuthorizationRuleArgs) ElementType() reflect.Type {
   172  	return reflect.TypeOf((*authorizationRuleArgs)(nil)).Elem()
   173  }
   174  
   175  type AuthorizationRuleInput interface {
   176  	pulumi.Input
   177  
   178  	ToAuthorizationRuleOutput() AuthorizationRuleOutput
   179  	ToAuthorizationRuleOutputWithContext(ctx context.Context) AuthorizationRuleOutput
   180  }
   181  
   182  func (*AuthorizationRule) ElementType() reflect.Type {
   183  	return reflect.TypeOf((**AuthorizationRule)(nil)).Elem()
   184  }
   185  
   186  func (i *AuthorizationRule) ToAuthorizationRuleOutput() AuthorizationRuleOutput {
   187  	return i.ToAuthorizationRuleOutputWithContext(context.Background())
   188  }
   189  
   190  func (i *AuthorizationRule) ToAuthorizationRuleOutputWithContext(ctx context.Context) AuthorizationRuleOutput {
   191  	return pulumi.ToOutputWithContext(ctx, i).(AuthorizationRuleOutput)
   192  }
   193  
   194  // AuthorizationRuleArrayInput is an input type that accepts AuthorizationRuleArray and AuthorizationRuleArrayOutput values.
   195  // You can construct a concrete instance of `AuthorizationRuleArrayInput` via:
   196  //
   197  //	AuthorizationRuleArray{ AuthorizationRuleArgs{...} }
   198  type AuthorizationRuleArrayInput interface {
   199  	pulumi.Input
   200  
   201  	ToAuthorizationRuleArrayOutput() AuthorizationRuleArrayOutput
   202  	ToAuthorizationRuleArrayOutputWithContext(context.Context) AuthorizationRuleArrayOutput
   203  }
   204  
   205  type AuthorizationRuleArray []AuthorizationRuleInput
   206  
   207  func (AuthorizationRuleArray) ElementType() reflect.Type {
   208  	return reflect.TypeOf((*[]*AuthorizationRule)(nil)).Elem()
   209  }
   210  
   211  func (i AuthorizationRuleArray) ToAuthorizationRuleArrayOutput() AuthorizationRuleArrayOutput {
   212  	return i.ToAuthorizationRuleArrayOutputWithContext(context.Background())
   213  }
   214  
   215  func (i AuthorizationRuleArray) ToAuthorizationRuleArrayOutputWithContext(ctx context.Context) AuthorizationRuleArrayOutput {
   216  	return pulumi.ToOutputWithContext(ctx, i).(AuthorizationRuleArrayOutput)
   217  }
   218  
   219  // AuthorizationRuleMapInput is an input type that accepts AuthorizationRuleMap and AuthorizationRuleMapOutput values.
   220  // You can construct a concrete instance of `AuthorizationRuleMapInput` via:
   221  //
   222  //	AuthorizationRuleMap{ "key": AuthorizationRuleArgs{...} }
   223  type AuthorizationRuleMapInput interface {
   224  	pulumi.Input
   225  
   226  	ToAuthorizationRuleMapOutput() AuthorizationRuleMapOutput
   227  	ToAuthorizationRuleMapOutputWithContext(context.Context) AuthorizationRuleMapOutput
   228  }
   229  
   230  type AuthorizationRuleMap map[string]AuthorizationRuleInput
   231  
   232  func (AuthorizationRuleMap) ElementType() reflect.Type {
   233  	return reflect.TypeOf((*map[string]*AuthorizationRule)(nil)).Elem()
   234  }
   235  
   236  func (i AuthorizationRuleMap) ToAuthorizationRuleMapOutput() AuthorizationRuleMapOutput {
   237  	return i.ToAuthorizationRuleMapOutputWithContext(context.Background())
   238  }
   239  
   240  func (i AuthorizationRuleMap) ToAuthorizationRuleMapOutputWithContext(ctx context.Context) AuthorizationRuleMapOutput {
   241  	return pulumi.ToOutputWithContext(ctx, i).(AuthorizationRuleMapOutput)
   242  }
   243  
   244  type AuthorizationRuleOutput struct{ *pulumi.OutputState }
   245  
   246  func (AuthorizationRuleOutput) ElementType() reflect.Type {
   247  	return reflect.TypeOf((**AuthorizationRule)(nil)).Elem()
   248  }
   249  
   250  func (o AuthorizationRuleOutput) ToAuthorizationRuleOutput() AuthorizationRuleOutput {
   251  	return o
   252  }
   253  
   254  func (o AuthorizationRuleOutput) ToAuthorizationRuleOutputWithContext(ctx context.Context) AuthorizationRuleOutput {
   255  	return o
   256  }
   257  
   258  // The ID of the group to which the authorization rule grants access. One of `accessGroupId` or `authorizeAllGroups` must be set.
   259  func (o AuthorizationRuleOutput) AccessGroupId() pulumi.StringPtrOutput {
   260  	return o.ApplyT(func(v *AuthorizationRule) pulumi.StringPtrOutput { return v.AccessGroupId }).(pulumi.StringPtrOutput)
   261  }
   262  
   263  // Indicates whether the authorization rule grants access to all clients. One of `accessGroupId` or `authorizeAllGroups` must be set.
   264  func (o AuthorizationRuleOutput) AuthorizeAllGroups() pulumi.BoolPtrOutput {
   265  	return o.ApplyT(func(v *AuthorizationRule) pulumi.BoolPtrOutput { return v.AuthorizeAllGroups }).(pulumi.BoolPtrOutput)
   266  }
   267  
   268  // The ID of the Client VPN endpoint.
   269  func (o AuthorizationRuleOutput) ClientVpnEndpointId() pulumi.StringOutput {
   270  	return o.ApplyT(func(v *AuthorizationRule) pulumi.StringOutput { return v.ClientVpnEndpointId }).(pulumi.StringOutput)
   271  }
   272  
   273  // A brief description of the authorization rule.
   274  func (o AuthorizationRuleOutput) Description() pulumi.StringPtrOutput {
   275  	return o.ApplyT(func(v *AuthorizationRule) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
   276  }
   277  
   278  // The IPv4 address range, in CIDR notation, of the network to which the authorization rule applies.
   279  func (o AuthorizationRuleOutput) TargetNetworkCidr() pulumi.StringOutput {
   280  	return o.ApplyT(func(v *AuthorizationRule) pulumi.StringOutput { return v.TargetNetworkCidr }).(pulumi.StringOutput)
   281  }
   282  
   283  type AuthorizationRuleArrayOutput struct{ *pulumi.OutputState }
   284  
   285  func (AuthorizationRuleArrayOutput) ElementType() reflect.Type {
   286  	return reflect.TypeOf((*[]*AuthorizationRule)(nil)).Elem()
   287  }
   288  
   289  func (o AuthorizationRuleArrayOutput) ToAuthorizationRuleArrayOutput() AuthorizationRuleArrayOutput {
   290  	return o
   291  }
   292  
   293  func (o AuthorizationRuleArrayOutput) ToAuthorizationRuleArrayOutputWithContext(ctx context.Context) AuthorizationRuleArrayOutput {
   294  	return o
   295  }
   296  
   297  func (o AuthorizationRuleArrayOutput) Index(i pulumi.IntInput) AuthorizationRuleOutput {
   298  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *AuthorizationRule {
   299  		return vs[0].([]*AuthorizationRule)[vs[1].(int)]
   300  	}).(AuthorizationRuleOutput)
   301  }
   302  
   303  type AuthorizationRuleMapOutput struct{ *pulumi.OutputState }
   304  
   305  func (AuthorizationRuleMapOutput) ElementType() reflect.Type {
   306  	return reflect.TypeOf((*map[string]*AuthorizationRule)(nil)).Elem()
   307  }
   308  
   309  func (o AuthorizationRuleMapOutput) ToAuthorizationRuleMapOutput() AuthorizationRuleMapOutput {
   310  	return o
   311  }
   312  
   313  func (o AuthorizationRuleMapOutput) ToAuthorizationRuleMapOutputWithContext(ctx context.Context) AuthorizationRuleMapOutput {
   314  	return o
   315  }
   316  
   317  func (o AuthorizationRuleMapOutput) MapIndex(k pulumi.StringInput) AuthorizationRuleOutput {
   318  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *AuthorizationRule {
   319  		return vs[0].(map[string]*AuthorizationRule)[vs[1].(string)]
   320  	}).(AuthorizationRuleOutput)
   321  }
   322  
   323  func init() {
   324  	pulumi.RegisterInputType(reflect.TypeOf((*AuthorizationRuleInput)(nil)).Elem(), &AuthorizationRule{})
   325  	pulumi.RegisterInputType(reflect.TypeOf((*AuthorizationRuleArrayInput)(nil)).Elem(), AuthorizationRuleArray{})
   326  	pulumi.RegisterInputType(reflect.TypeOf((*AuthorizationRuleMapInput)(nil)).Elem(), AuthorizationRuleMap{})
   327  	pulumi.RegisterOutputType(AuthorizationRuleOutput{})
   328  	pulumi.RegisterOutputType(AuthorizationRuleArrayOutput{})
   329  	pulumi.RegisterOutputType(AuthorizationRuleMapOutput{})
   330  }