github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ram/principalAssociation.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 ram
     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 Resource Access Manager (RAM) principal association. Depending if [RAM Sharing with AWS Organizations is enabled](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-sharing.html#getting-started-sharing-orgs), the RAM behavior with different principal types changes.
    16  //
    17  // When RAM Sharing with AWS Organizations is enabled:
    18  //
    19  // - For AWS Account ID, Organization, and Organizational Unit principals within the same AWS Organization, no resource share invitation is sent and resources become available automatically after creating the association.
    20  // - For AWS Account ID principals outside the AWS Organization, a resource share invitation is sent and must be accepted before resources become available. See the `ram.ResourceShareAccepter` resource to accept these invitations.
    21  //
    22  // When RAM Sharing with AWS Organizations is not enabled:
    23  //
    24  // - Organization and Organizational Unit principals cannot be used.
    25  // - For AWS Account ID principals, a resource share invitation is sent and must be accepted before resources become available. See the `ram.ResourceShareAccepter` resource to accept these invitations.
    26  //
    27  // ## Example Usage
    28  //
    29  // ### AWS Account ID
    30  //
    31  // <!--Start PulumiCodeChooser -->
    32  // ```go
    33  // package main
    34  //
    35  // import (
    36  //
    37  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ram"
    38  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    39  //
    40  // )
    41  //
    42  //	func main() {
    43  //		pulumi.Run(func(ctx *pulumi.Context) error {
    44  //			example, err := ram.NewResourceShare(ctx, "example", &ram.ResourceShareArgs{
    45  //				AllowExternalPrincipals: pulumi.Bool(true),
    46  //			})
    47  //			if err != nil {
    48  //				return err
    49  //			}
    50  //			_, err = ram.NewPrincipalAssociation(ctx, "example", &ram.PrincipalAssociationArgs{
    51  //				Principal:        pulumi.String("111111111111"),
    52  //				ResourceShareArn: example.Arn,
    53  //			})
    54  //			if err != nil {
    55  //				return err
    56  //			}
    57  //			return nil
    58  //		})
    59  //	}
    60  //
    61  // ```
    62  // <!--End PulumiCodeChooser -->
    63  //
    64  // ### AWS Organization
    65  //
    66  // <!--Start PulumiCodeChooser -->
    67  // ```go
    68  // package main
    69  //
    70  // import (
    71  //
    72  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ram"
    73  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    74  //
    75  // )
    76  //
    77  //	func main() {
    78  //		pulumi.Run(func(ctx *pulumi.Context) error {
    79  //			_, err := ram.NewPrincipalAssociation(ctx, "example", &ram.PrincipalAssociationArgs{
    80  //				Principal:        pulumi.Any(exampleAwsOrganizationsOrganization.Arn),
    81  //				ResourceShareArn: pulumi.Any(exampleAwsRamResourceShare.Arn),
    82  //			})
    83  //			if err != nil {
    84  //				return err
    85  //			}
    86  //			return nil
    87  //		})
    88  //	}
    89  //
    90  // ```
    91  // <!--End PulumiCodeChooser -->
    92  //
    93  // ## Import
    94  //
    95  // Using `pulumi import`, import RAM Principal Associations using their Resource Share ARN and the `principal` separated by a comma. For example:
    96  //
    97  // ```sh
    98  // $ pulumi import aws:ram/principalAssociation:PrincipalAssociation example arn:aws:ram:eu-west-1:123456789012:resource-share/73da1ab9-b94a-4ba3-8eb4-45917f7f4b12,123456789012
    99  // ```
   100  type PrincipalAssociation struct {
   101  	pulumi.CustomResourceState
   102  
   103  	// The principal to associate with the resource share. Possible values are an AWS account ID, an AWS Organizations Organization ARN, or an AWS Organizations Organization Unit ARN.
   104  	Principal pulumi.StringOutput `pulumi:"principal"`
   105  	// The Amazon Resource Name (ARN) of the resource share.
   106  	ResourceShareArn pulumi.StringOutput `pulumi:"resourceShareArn"`
   107  }
   108  
   109  // NewPrincipalAssociation registers a new resource with the given unique name, arguments, and options.
   110  func NewPrincipalAssociation(ctx *pulumi.Context,
   111  	name string, args *PrincipalAssociationArgs, opts ...pulumi.ResourceOption) (*PrincipalAssociation, error) {
   112  	if args == nil {
   113  		return nil, errors.New("missing one or more required arguments")
   114  	}
   115  
   116  	if args.Principal == nil {
   117  		return nil, errors.New("invalid value for required argument 'Principal'")
   118  	}
   119  	if args.ResourceShareArn == nil {
   120  		return nil, errors.New("invalid value for required argument 'ResourceShareArn'")
   121  	}
   122  	opts = internal.PkgResourceDefaultOpts(opts)
   123  	var resource PrincipalAssociation
   124  	err := ctx.RegisterResource("aws:ram/principalAssociation:PrincipalAssociation", name, args, &resource, opts...)
   125  	if err != nil {
   126  		return nil, err
   127  	}
   128  	return &resource, nil
   129  }
   130  
   131  // GetPrincipalAssociation gets an existing PrincipalAssociation resource's state with the given name, ID, and optional
   132  // state properties that are used to uniquely qualify the lookup (nil if not required).
   133  func GetPrincipalAssociation(ctx *pulumi.Context,
   134  	name string, id pulumi.IDInput, state *PrincipalAssociationState, opts ...pulumi.ResourceOption) (*PrincipalAssociation, error) {
   135  	var resource PrincipalAssociation
   136  	err := ctx.ReadResource("aws:ram/principalAssociation:PrincipalAssociation", name, id, state, &resource, opts...)
   137  	if err != nil {
   138  		return nil, err
   139  	}
   140  	return &resource, nil
   141  }
   142  
   143  // Input properties used for looking up and filtering PrincipalAssociation resources.
   144  type principalAssociationState struct {
   145  	// The principal to associate with the resource share. Possible values are an AWS account ID, an AWS Organizations Organization ARN, or an AWS Organizations Organization Unit ARN.
   146  	Principal *string `pulumi:"principal"`
   147  	// The Amazon Resource Name (ARN) of the resource share.
   148  	ResourceShareArn *string `pulumi:"resourceShareArn"`
   149  }
   150  
   151  type PrincipalAssociationState struct {
   152  	// The principal to associate with the resource share. Possible values are an AWS account ID, an AWS Organizations Organization ARN, or an AWS Organizations Organization Unit ARN.
   153  	Principal pulumi.StringPtrInput
   154  	// The Amazon Resource Name (ARN) of the resource share.
   155  	ResourceShareArn pulumi.StringPtrInput
   156  }
   157  
   158  func (PrincipalAssociationState) ElementType() reflect.Type {
   159  	return reflect.TypeOf((*principalAssociationState)(nil)).Elem()
   160  }
   161  
   162  type principalAssociationArgs struct {
   163  	// The principal to associate with the resource share. Possible values are an AWS account ID, an AWS Organizations Organization ARN, or an AWS Organizations Organization Unit ARN.
   164  	Principal string `pulumi:"principal"`
   165  	// The Amazon Resource Name (ARN) of the resource share.
   166  	ResourceShareArn string `pulumi:"resourceShareArn"`
   167  }
   168  
   169  // The set of arguments for constructing a PrincipalAssociation resource.
   170  type PrincipalAssociationArgs struct {
   171  	// The principal to associate with the resource share. Possible values are an AWS account ID, an AWS Organizations Organization ARN, or an AWS Organizations Organization Unit ARN.
   172  	Principal pulumi.StringInput
   173  	// The Amazon Resource Name (ARN) of the resource share.
   174  	ResourceShareArn pulumi.StringInput
   175  }
   176  
   177  func (PrincipalAssociationArgs) ElementType() reflect.Type {
   178  	return reflect.TypeOf((*principalAssociationArgs)(nil)).Elem()
   179  }
   180  
   181  type PrincipalAssociationInput interface {
   182  	pulumi.Input
   183  
   184  	ToPrincipalAssociationOutput() PrincipalAssociationOutput
   185  	ToPrincipalAssociationOutputWithContext(ctx context.Context) PrincipalAssociationOutput
   186  }
   187  
   188  func (*PrincipalAssociation) ElementType() reflect.Type {
   189  	return reflect.TypeOf((**PrincipalAssociation)(nil)).Elem()
   190  }
   191  
   192  func (i *PrincipalAssociation) ToPrincipalAssociationOutput() PrincipalAssociationOutput {
   193  	return i.ToPrincipalAssociationOutputWithContext(context.Background())
   194  }
   195  
   196  func (i *PrincipalAssociation) ToPrincipalAssociationOutputWithContext(ctx context.Context) PrincipalAssociationOutput {
   197  	return pulumi.ToOutputWithContext(ctx, i).(PrincipalAssociationOutput)
   198  }
   199  
   200  // PrincipalAssociationArrayInput is an input type that accepts PrincipalAssociationArray and PrincipalAssociationArrayOutput values.
   201  // You can construct a concrete instance of `PrincipalAssociationArrayInput` via:
   202  //
   203  //	PrincipalAssociationArray{ PrincipalAssociationArgs{...} }
   204  type PrincipalAssociationArrayInput interface {
   205  	pulumi.Input
   206  
   207  	ToPrincipalAssociationArrayOutput() PrincipalAssociationArrayOutput
   208  	ToPrincipalAssociationArrayOutputWithContext(context.Context) PrincipalAssociationArrayOutput
   209  }
   210  
   211  type PrincipalAssociationArray []PrincipalAssociationInput
   212  
   213  func (PrincipalAssociationArray) ElementType() reflect.Type {
   214  	return reflect.TypeOf((*[]*PrincipalAssociation)(nil)).Elem()
   215  }
   216  
   217  func (i PrincipalAssociationArray) ToPrincipalAssociationArrayOutput() PrincipalAssociationArrayOutput {
   218  	return i.ToPrincipalAssociationArrayOutputWithContext(context.Background())
   219  }
   220  
   221  func (i PrincipalAssociationArray) ToPrincipalAssociationArrayOutputWithContext(ctx context.Context) PrincipalAssociationArrayOutput {
   222  	return pulumi.ToOutputWithContext(ctx, i).(PrincipalAssociationArrayOutput)
   223  }
   224  
   225  // PrincipalAssociationMapInput is an input type that accepts PrincipalAssociationMap and PrincipalAssociationMapOutput values.
   226  // You can construct a concrete instance of `PrincipalAssociationMapInput` via:
   227  //
   228  //	PrincipalAssociationMap{ "key": PrincipalAssociationArgs{...} }
   229  type PrincipalAssociationMapInput interface {
   230  	pulumi.Input
   231  
   232  	ToPrincipalAssociationMapOutput() PrincipalAssociationMapOutput
   233  	ToPrincipalAssociationMapOutputWithContext(context.Context) PrincipalAssociationMapOutput
   234  }
   235  
   236  type PrincipalAssociationMap map[string]PrincipalAssociationInput
   237  
   238  func (PrincipalAssociationMap) ElementType() reflect.Type {
   239  	return reflect.TypeOf((*map[string]*PrincipalAssociation)(nil)).Elem()
   240  }
   241  
   242  func (i PrincipalAssociationMap) ToPrincipalAssociationMapOutput() PrincipalAssociationMapOutput {
   243  	return i.ToPrincipalAssociationMapOutputWithContext(context.Background())
   244  }
   245  
   246  func (i PrincipalAssociationMap) ToPrincipalAssociationMapOutputWithContext(ctx context.Context) PrincipalAssociationMapOutput {
   247  	return pulumi.ToOutputWithContext(ctx, i).(PrincipalAssociationMapOutput)
   248  }
   249  
   250  type PrincipalAssociationOutput struct{ *pulumi.OutputState }
   251  
   252  func (PrincipalAssociationOutput) ElementType() reflect.Type {
   253  	return reflect.TypeOf((**PrincipalAssociation)(nil)).Elem()
   254  }
   255  
   256  func (o PrincipalAssociationOutput) ToPrincipalAssociationOutput() PrincipalAssociationOutput {
   257  	return o
   258  }
   259  
   260  func (o PrincipalAssociationOutput) ToPrincipalAssociationOutputWithContext(ctx context.Context) PrincipalAssociationOutput {
   261  	return o
   262  }
   263  
   264  // The principal to associate with the resource share. Possible values are an AWS account ID, an AWS Organizations Organization ARN, or an AWS Organizations Organization Unit ARN.
   265  func (o PrincipalAssociationOutput) Principal() pulumi.StringOutput {
   266  	return o.ApplyT(func(v *PrincipalAssociation) pulumi.StringOutput { return v.Principal }).(pulumi.StringOutput)
   267  }
   268  
   269  // The Amazon Resource Name (ARN) of the resource share.
   270  func (o PrincipalAssociationOutput) ResourceShareArn() pulumi.StringOutput {
   271  	return o.ApplyT(func(v *PrincipalAssociation) pulumi.StringOutput { return v.ResourceShareArn }).(pulumi.StringOutput)
   272  }
   273  
   274  type PrincipalAssociationArrayOutput struct{ *pulumi.OutputState }
   275  
   276  func (PrincipalAssociationArrayOutput) ElementType() reflect.Type {
   277  	return reflect.TypeOf((*[]*PrincipalAssociation)(nil)).Elem()
   278  }
   279  
   280  func (o PrincipalAssociationArrayOutput) ToPrincipalAssociationArrayOutput() PrincipalAssociationArrayOutput {
   281  	return o
   282  }
   283  
   284  func (o PrincipalAssociationArrayOutput) ToPrincipalAssociationArrayOutputWithContext(ctx context.Context) PrincipalAssociationArrayOutput {
   285  	return o
   286  }
   287  
   288  func (o PrincipalAssociationArrayOutput) Index(i pulumi.IntInput) PrincipalAssociationOutput {
   289  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *PrincipalAssociation {
   290  		return vs[0].([]*PrincipalAssociation)[vs[1].(int)]
   291  	}).(PrincipalAssociationOutput)
   292  }
   293  
   294  type PrincipalAssociationMapOutput struct{ *pulumi.OutputState }
   295  
   296  func (PrincipalAssociationMapOutput) ElementType() reflect.Type {
   297  	return reflect.TypeOf((*map[string]*PrincipalAssociation)(nil)).Elem()
   298  }
   299  
   300  func (o PrincipalAssociationMapOutput) ToPrincipalAssociationMapOutput() PrincipalAssociationMapOutput {
   301  	return o
   302  }
   303  
   304  func (o PrincipalAssociationMapOutput) ToPrincipalAssociationMapOutputWithContext(ctx context.Context) PrincipalAssociationMapOutput {
   305  	return o
   306  }
   307  
   308  func (o PrincipalAssociationMapOutput) MapIndex(k pulumi.StringInput) PrincipalAssociationOutput {
   309  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *PrincipalAssociation {
   310  		return vs[0].(map[string]*PrincipalAssociation)[vs[1].(string)]
   311  	}).(PrincipalAssociationOutput)
   312  }
   313  
   314  func init() {
   315  	pulumi.RegisterInputType(reflect.TypeOf((*PrincipalAssociationInput)(nil)).Elem(), &PrincipalAssociation{})
   316  	pulumi.RegisterInputType(reflect.TypeOf((*PrincipalAssociationArrayInput)(nil)).Elem(), PrincipalAssociationArray{})
   317  	pulumi.RegisterInputType(reflect.TypeOf((*PrincipalAssociationMapInput)(nil)).Elem(), PrincipalAssociationMap{})
   318  	pulumi.RegisterOutputType(PrincipalAssociationOutput{})
   319  	pulumi.RegisterOutputType(PrincipalAssociationArrayOutput{})
   320  	pulumi.RegisterOutputType(PrincipalAssociationMapOutput{})
   321  }