github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/vpclattice/authPolicy.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 vpclattice
     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  // Resource for managing an AWS VPC Lattice Auth Policy.
    16  //
    17  // ## Example Usage
    18  //
    19  // ### Basic Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"encoding/json"
    28  //
    29  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/vpclattice"
    30  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			example, err := vpclattice.NewService(ctx, "example", &vpclattice.ServiceArgs{
    37  //				Name:             pulumi.String("example-vpclattice-service"),
    38  //				AuthType:         pulumi.String("AWS_IAM"),
    39  //				CustomDomainName: pulumi.String("example.com"),
    40  //			})
    41  //			if err != nil {
    42  //				return err
    43  //			}
    44  //			tmpJSON0, err := json.Marshal(map[string]interface{}{
    45  //				"Version": "2012-10-17",
    46  //				"Statement": []map[string]interface{}{
    47  //					map[string]interface{}{
    48  //						"Action":    "*",
    49  //						"Effect":    "Allow",
    50  //						"Principal": "*",
    51  //						"Resource":  "*",
    52  //						"Condition": map[string]interface{}{
    53  //							"StringNotEqualsIgnoreCase": map[string]interface{}{
    54  //								"aws:PrincipalType": "anonymous",
    55  //							},
    56  //						},
    57  //					},
    58  //				},
    59  //			})
    60  //			if err != nil {
    61  //				return err
    62  //			}
    63  //			json0 := string(tmpJSON0)
    64  //			_, err = vpclattice.NewAuthPolicy(ctx, "example", &vpclattice.AuthPolicyArgs{
    65  //				ResourceIdentifier: example.Arn,
    66  //				Policy:             pulumi.String(json0),
    67  //			})
    68  //			if err != nil {
    69  //				return err
    70  //			}
    71  //			return nil
    72  //		})
    73  //	}
    74  //
    75  // ```
    76  // <!--End PulumiCodeChooser -->
    77  //
    78  // ## Import
    79  //
    80  // Using `pulumi import`, import VPC Lattice Auth Policy using the `id`. For example:
    81  //
    82  // ```sh
    83  // $ pulumi import aws:vpclattice/authPolicy:AuthPolicy example abcd-12345678
    84  // ```
    85  type AuthPolicy struct {
    86  	pulumi.CustomResourceState
    87  
    88  	// The auth policy. The policy string in JSON must not contain newlines or blank lines.
    89  	Policy pulumi.StringOutput `pulumi:"policy"`
    90  	// The ID or Amazon Resource Name (ARN) of the service network or service for which the policy is created.
    91  	ResourceIdentifier pulumi.StringOutput `pulumi:"resourceIdentifier"`
    92  	// The state of the auth policy. The auth policy is only active when the auth type is set to `AWS_IAM`. If you provide a policy, then authentication and authorization decisions are made based on this policy and the client's IAM policy. If the Auth type is `NONE`, then, any auth policy you provide will remain inactive.
    93  	State pulumi.StringPtrOutput `pulumi:"state"`
    94  }
    95  
    96  // NewAuthPolicy registers a new resource with the given unique name, arguments, and options.
    97  func NewAuthPolicy(ctx *pulumi.Context,
    98  	name string, args *AuthPolicyArgs, opts ...pulumi.ResourceOption) (*AuthPolicy, error) {
    99  	if args == nil {
   100  		return nil, errors.New("missing one or more required arguments")
   101  	}
   102  
   103  	if args.Policy == nil {
   104  		return nil, errors.New("invalid value for required argument 'Policy'")
   105  	}
   106  	if args.ResourceIdentifier == nil {
   107  		return nil, errors.New("invalid value for required argument 'ResourceIdentifier'")
   108  	}
   109  	opts = internal.PkgResourceDefaultOpts(opts)
   110  	var resource AuthPolicy
   111  	err := ctx.RegisterResource("aws:vpclattice/authPolicy:AuthPolicy", name, args, &resource, opts...)
   112  	if err != nil {
   113  		return nil, err
   114  	}
   115  	return &resource, nil
   116  }
   117  
   118  // GetAuthPolicy gets an existing AuthPolicy resource's state with the given name, ID, and optional
   119  // state properties that are used to uniquely qualify the lookup (nil if not required).
   120  func GetAuthPolicy(ctx *pulumi.Context,
   121  	name string, id pulumi.IDInput, state *AuthPolicyState, opts ...pulumi.ResourceOption) (*AuthPolicy, error) {
   122  	var resource AuthPolicy
   123  	err := ctx.ReadResource("aws:vpclattice/authPolicy:AuthPolicy", name, id, state, &resource, opts...)
   124  	if err != nil {
   125  		return nil, err
   126  	}
   127  	return &resource, nil
   128  }
   129  
   130  // Input properties used for looking up and filtering AuthPolicy resources.
   131  type authPolicyState struct {
   132  	// The auth policy. The policy string in JSON must not contain newlines or blank lines.
   133  	Policy *string `pulumi:"policy"`
   134  	// The ID or Amazon Resource Name (ARN) of the service network or service for which the policy is created.
   135  	ResourceIdentifier *string `pulumi:"resourceIdentifier"`
   136  	// The state of the auth policy. The auth policy is only active when the auth type is set to `AWS_IAM`. If you provide a policy, then authentication and authorization decisions are made based on this policy and the client's IAM policy. If the Auth type is `NONE`, then, any auth policy you provide will remain inactive.
   137  	State *string `pulumi:"state"`
   138  }
   139  
   140  type AuthPolicyState struct {
   141  	// The auth policy. The policy string in JSON must not contain newlines or blank lines.
   142  	Policy pulumi.StringPtrInput
   143  	// The ID or Amazon Resource Name (ARN) of the service network or service for which the policy is created.
   144  	ResourceIdentifier pulumi.StringPtrInput
   145  	// The state of the auth policy. The auth policy is only active when the auth type is set to `AWS_IAM`. If you provide a policy, then authentication and authorization decisions are made based on this policy and the client's IAM policy. If the Auth type is `NONE`, then, any auth policy you provide will remain inactive.
   146  	State pulumi.StringPtrInput
   147  }
   148  
   149  func (AuthPolicyState) ElementType() reflect.Type {
   150  	return reflect.TypeOf((*authPolicyState)(nil)).Elem()
   151  }
   152  
   153  type authPolicyArgs struct {
   154  	// The auth policy. The policy string in JSON must not contain newlines or blank lines.
   155  	Policy string `pulumi:"policy"`
   156  	// The ID or Amazon Resource Name (ARN) of the service network or service for which the policy is created.
   157  	ResourceIdentifier string `pulumi:"resourceIdentifier"`
   158  	// The state of the auth policy. The auth policy is only active when the auth type is set to `AWS_IAM`. If you provide a policy, then authentication and authorization decisions are made based on this policy and the client's IAM policy. If the Auth type is `NONE`, then, any auth policy you provide will remain inactive.
   159  	State *string `pulumi:"state"`
   160  }
   161  
   162  // The set of arguments for constructing a AuthPolicy resource.
   163  type AuthPolicyArgs struct {
   164  	// The auth policy. The policy string in JSON must not contain newlines or blank lines.
   165  	Policy pulumi.StringInput
   166  	// The ID or Amazon Resource Name (ARN) of the service network or service for which the policy is created.
   167  	ResourceIdentifier pulumi.StringInput
   168  	// The state of the auth policy. The auth policy is only active when the auth type is set to `AWS_IAM`. If you provide a policy, then authentication and authorization decisions are made based on this policy and the client's IAM policy. If the Auth type is `NONE`, then, any auth policy you provide will remain inactive.
   169  	State pulumi.StringPtrInput
   170  }
   171  
   172  func (AuthPolicyArgs) ElementType() reflect.Type {
   173  	return reflect.TypeOf((*authPolicyArgs)(nil)).Elem()
   174  }
   175  
   176  type AuthPolicyInput interface {
   177  	pulumi.Input
   178  
   179  	ToAuthPolicyOutput() AuthPolicyOutput
   180  	ToAuthPolicyOutputWithContext(ctx context.Context) AuthPolicyOutput
   181  }
   182  
   183  func (*AuthPolicy) ElementType() reflect.Type {
   184  	return reflect.TypeOf((**AuthPolicy)(nil)).Elem()
   185  }
   186  
   187  func (i *AuthPolicy) ToAuthPolicyOutput() AuthPolicyOutput {
   188  	return i.ToAuthPolicyOutputWithContext(context.Background())
   189  }
   190  
   191  func (i *AuthPolicy) ToAuthPolicyOutputWithContext(ctx context.Context) AuthPolicyOutput {
   192  	return pulumi.ToOutputWithContext(ctx, i).(AuthPolicyOutput)
   193  }
   194  
   195  // AuthPolicyArrayInput is an input type that accepts AuthPolicyArray and AuthPolicyArrayOutput values.
   196  // You can construct a concrete instance of `AuthPolicyArrayInput` via:
   197  //
   198  //	AuthPolicyArray{ AuthPolicyArgs{...} }
   199  type AuthPolicyArrayInput interface {
   200  	pulumi.Input
   201  
   202  	ToAuthPolicyArrayOutput() AuthPolicyArrayOutput
   203  	ToAuthPolicyArrayOutputWithContext(context.Context) AuthPolicyArrayOutput
   204  }
   205  
   206  type AuthPolicyArray []AuthPolicyInput
   207  
   208  func (AuthPolicyArray) ElementType() reflect.Type {
   209  	return reflect.TypeOf((*[]*AuthPolicy)(nil)).Elem()
   210  }
   211  
   212  func (i AuthPolicyArray) ToAuthPolicyArrayOutput() AuthPolicyArrayOutput {
   213  	return i.ToAuthPolicyArrayOutputWithContext(context.Background())
   214  }
   215  
   216  func (i AuthPolicyArray) ToAuthPolicyArrayOutputWithContext(ctx context.Context) AuthPolicyArrayOutput {
   217  	return pulumi.ToOutputWithContext(ctx, i).(AuthPolicyArrayOutput)
   218  }
   219  
   220  // AuthPolicyMapInput is an input type that accepts AuthPolicyMap and AuthPolicyMapOutput values.
   221  // You can construct a concrete instance of `AuthPolicyMapInput` via:
   222  //
   223  //	AuthPolicyMap{ "key": AuthPolicyArgs{...} }
   224  type AuthPolicyMapInput interface {
   225  	pulumi.Input
   226  
   227  	ToAuthPolicyMapOutput() AuthPolicyMapOutput
   228  	ToAuthPolicyMapOutputWithContext(context.Context) AuthPolicyMapOutput
   229  }
   230  
   231  type AuthPolicyMap map[string]AuthPolicyInput
   232  
   233  func (AuthPolicyMap) ElementType() reflect.Type {
   234  	return reflect.TypeOf((*map[string]*AuthPolicy)(nil)).Elem()
   235  }
   236  
   237  func (i AuthPolicyMap) ToAuthPolicyMapOutput() AuthPolicyMapOutput {
   238  	return i.ToAuthPolicyMapOutputWithContext(context.Background())
   239  }
   240  
   241  func (i AuthPolicyMap) ToAuthPolicyMapOutputWithContext(ctx context.Context) AuthPolicyMapOutput {
   242  	return pulumi.ToOutputWithContext(ctx, i).(AuthPolicyMapOutput)
   243  }
   244  
   245  type AuthPolicyOutput struct{ *pulumi.OutputState }
   246  
   247  func (AuthPolicyOutput) ElementType() reflect.Type {
   248  	return reflect.TypeOf((**AuthPolicy)(nil)).Elem()
   249  }
   250  
   251  func (o AuthPolicyOutput) ToAuthPolicyOutput() AuthPolicyOutput {
   252  	return o
   253  }
   254  
   255  func (o AuthPolicyOutput) ToAuthPolicyOutputWithContext(ctx context.Context) AuthPolicyOutput {
   256  	return o
   257  }
   258  
   259  // The auth policy. The policy string in JSON must not contain newlines or blank lines.
   260  func (o AuthPolicyOutput) Policy() pulumi.StringOutput {
   261  	return o.ApplyT(func(v *AuthPolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)
   262  }
   263  
   264  // The ID or Amazon Resource Name (ARN) of the service network or service for which the policy is created.
   265  func (o AuthPolicyOutput) ResourceIdentifier() pulumi.StringOutput {
   266  	return o.ApplyT(func(v *AuthPolicy) pulumi.StringOutput { return v.ResourceIdentifier }).(pulumi.StringOutput)
   267  }
   268  
   269  // The state of the auth policy. The auth policy is only active when the auth type is set to `AWS_IAM`. If you provide a policy, then authentication and authorization decisions are made based on this policy and the client's IAM policy. If the Auth type is `NONE`, then, any auth policy you provide will remain inactive.
   270  func (o AuthPolicyOutput) State() pulumi.StringPtrOutput {
   271  	return o.ApplyT(func(v *AuthPolicy) pulumi.StringPtrOutput { return v.State }).(pulumi.StringPtrOutput)
   272  }
   273  
   274  type AuthPolicyArrayOutput struct{ *pulumi.OutputState }
   275  
   276  func (AuthPolicyArrayOutput) ElementType() reflect.Type {
   277  	return reflect.TypeOf((*[]*AuthPolicy)(nil)).Elem()
   278  }
   279  
   280  func (o AuthPolicyArrayOutput) ToAuthPolicyArrayOutput() AuthPolicyArrayOutput {
   281  	return o
   282  }
   283  
   284  func (o AuthPolicyArrayOutput) ToAuthPolicyArrayOutputWithContext(ctx context.Context) AuthPolicyArrayOutput {
   285  	return o
   286  }
   287  
   288  func (o AuthPolicyArrayOutput) Index(i pulumi.IntInput) AuthPolicyOutput {
   289  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *AuthPolicy {
   290  		return vs[0].([]*AuthPolicy)[vs[1].(int)]
   291  	}).(AuthPolicyOutput)
   292  }
   293  
   294  type AuthPolicyMapOutput struct{ *pulumi.OutputState }
   295  
   296  func (AuthPolicyMapOutput) ElementType() reflect.Type {
   297  	return reflect.TypeOf((*map[string]*AuthPolicy)(nil)).Elem()
   298  }
   299  
   300  func (o AuthPolicyMapOutput) ToAuthPolicyMapOutput() AuthPolicyMapOutput {
   301  	return o
   302  }
   303  
   304  func (o AuthPolicyMapOutput) ToAuthPolicyMapOutputWithContext(ctx context.Context) AuthPolicyMapOutput {
   305  	return o
   306  }
   307  
   308  func (o AuthPolicyMapOutput) MapIndex(k pulumi.StringInput) AuthPolicyOutput {
   309  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *AuthPolicy {
   310  		return vs[0].(map[string]*AuthPolicy)[vs[1].(string)]
   311  	}).(AuthPolicyOutput)
   312  }
   313  
   314  func init() {
   315  	pulumi.RegisterInputType(reflect.TypeOf((*AuthPolicyInput)(nil)).Elem(), &AuthPolicy{})
   316  	pulumi.RegisterInputType(reflect.TypeOf((*AuthPolicyArrayInput)(nil)).Elem(), AuthPolicyArray{})
   317  	pulumi.RegisterInputType(reflect.TypeOf((*AuthPolicyMapInput)(nil)).Elem(), AuthPolicyMap{})
   318  	pulumi.RegisterOutputType(AuthPolicyOutput{})
   319  	pulumi.RegisterOutputType(AuthPolicyArrayOutput{})
   320  	pulumi.RegisterOutputType(AuthPolicyMapOutput{})
   321  }