github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/organizations/resourcePolicy.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 organizations
     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 to manage a resource-based delegation policy that can be used to delegate policy management for AWS Organizations to specified member accounts to perform policy actions that are by default available only to the management account. See the [_AWS Organizations User Guide_](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_delegate_policies.html) for more information.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/organizations"
    26  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    27  //
    28  // )
    29  //
    30  //	func main() {
    31  //		pulumi.Run(func(ctx *pulumi.Context) error {
    32  //			_, err := organizations.NewResourcePolicy(ctx, "example", &organizations.ResourcePolicyArgs{
    33  //				Content: pulumi.String(`{
    34  //	  "Version": "2012-10-17",
    35  //	  "Statement": [
    36  //	    {
    37  //	      "Sid": "DelegatingNecessaryDescribeListActions",
    38  //	      "Effect": "Allow",
    39  //	      "Principal": {
    40  //	        "AWS": "arn:aws:iam::123456789012:root"
    41  //	      },
    42  //	      "Action": [
    43  //	        "organizations:DescribeOrganization",
    44  //	        "organizations:DescribeOrganizationalUnit",
    45  //	        "organizations:DescribeAccount",
    46  //	        "organizations:DescribePolicy",
    47  //	        "organizations:DescribeEffectivePolicy",
    48  //	        "organizations:ListRoots",
    49  //	        "organizations:ListOrganizationalUnitsForParent",
    50  //	        "organizations:ListParents",
    51  //	        "organizations:ListChildren",
    52  //	        "organizations:ListAccounts",
    53  //	        "organizations:ListAccountsForParent",
    54  //	        "organizations:ListPolicies",
    55  //	        "organizations:ListPoliciesForTarget",
    56  //	        "organizations:ListTargetsForPolicy",
    57  //	        "organizations:ListTagsForResource"
    58  //	      ],
    59  //	      "Resource": "*"
    60  //	    }
    61  //	  ]
    62  //	}
    63  //
    64  // `),
    65  //
    66  //			})
    67  //			if err != nil {
    68  //				return err
    69  //			}
    70  //			return nil
    71  //		})
    72  //	}
    73  //
    74  // ```
    75  // <!--End PulumiCodeChooser -->
    76  //
    77  // ## Import
    78  //
    79  // Using `pulumi import`, import `aws_organizations_resource_policy` using the resource policy ID. For example:
    80  //
    81  // ```sh
    82  // $ pulumi import aws:organizations/resourcePolicy:ResourcePolicy example rp-12345678
    83  // ```
    84  type ResourcePolicy struct {
    85  	pulumi.CustomResourceState
    86  
    87  	// Amazon Resource Name (ARN) of the resource policy.
    88  	Arn pulumi.StringOutput `pulumi:"arn"`
    89  	// Content for the resource policy. The text must be correctly formatted JSON that complies with the syntax for the resource policy's type. See the [_AWS Organizations User Guide_](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_delegate_examples.html) for examples.
    90  	Content pulumi.StringOutput `pulumi:"content"`
    91  	// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
    92  	Tags pulumi.StringMapOutput `pulumi:"tags"`
    93  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
    94  	//
    95  	// Deprecated: Please use `tags` instead.
    96  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
    97  }
    98  
    99  // NewResourcePolicy registers a new resource with the given unique name, arguments, and options.
   100  func NewResourcePolicy(ctx *pulumi.Context,
   101  	name string, args *ResourcePolicyArgs, opts ...pulumi.ResourceOption) (*ResourcePolicy, error) {
   102  	if args == nil {
   103  		return nil, errors.New("missing one or more required arguments")
   104  	}
   105  
   106  	if args.Content == nil {
   107  		return nil, errors.New("invalid value for required argument 'Content'")
   108  	}
   109  	opts = internal.PkgResourceDefaultOpts(opts)
   110  	var resource ResourcePolicy
   111  	err := ctx.RegisterResource("aws:organizations/resourcePolicy:ResourcePolicy", name, args, &resource, opts...)
   112  	if err != nil {
   113  		return nil, err
   114  	}
   115  	return &resource, nil
   116  }
   117  
   118  // GetResourcePolicy gets an existing ResourcePolicy 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 GetResourcePolicy(ctx *pulumi.Context,
   121  	name string, id pulumi.IDInput, state *ResourcePolicyState, opts ...pulumi.ResourceOption) (*ResourcePolicy, error) {
   122  	var resource ResourcePolicy
   123  	err := ctx.ReadResource("aws:organizations/resourcePolicy:ResourcePolicy", 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 ResourcePolicy resources.
   131  type resourcePolicyState struct {
   132  	// Amazon Resource Name (ARN) of the resource policy.
   133  	Arn *string `pulumi:"arn"`
   134  	// Content for the resource policy. The text must be correctly formatted JSON that complies with the syntax for the resource policy's type. See the [_AWS Organizations User Guide_](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_delegate_examples.html) for examples.
   135  	Content *string `pulumi:"content"`
   136  	// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   137  	Tags map[string]string `pulumi:"tags"`
   138  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   139  	//
   140  	// Deprecated: Please use `tags` instead.
   141  	TagsAll map[string]string `pulumi:"tagsAll"`
   142  }
   143  
   144  type ResourcePolicyState struct {
   145  	// Amazon Resource Name (ARN) of the resource policy.
   146  	Arn pulumi.StringPtrInput
   147  	// Content for the resource policy. The text must be correctly formatted JSON that complies with the syntax for the resource policy's type. See the [_AWS Organizations User Guide_](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_delegate_examples.html) for examples.
   148  	Content pulumi.StringPtrInput
   149  	// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   150  	Tags pulumi.StringMapInput
   151  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   152  	//
   153  	// Deprecated: Please use `tags` instead.
   154  	TagsAll pulumi.StringMapInput
   155  }
   156  
   157  func (ResourcePolicyState) ElementType() reflect.Type {
   158  	return reflect.TypeOf((*resourcePolicyState)(nil)).Elem()
   159  }
   160  
   161  type resourcePolicyArgs struct {
   162  	// Content for the resource policy. The text must be correctly formatted JSON that complies with the syntax for the resource policy's type. See the [_AWS Organizations User Guide_](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_delegate_examples.html) for examples.
   163  	Content string `pulumi:"content"`
   164  	// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   165  	Tags map[string]string `pulumi:"tags"`
   166  }
   167  
   168  // The set of arguments for constructing a ResourcePolicy resource.
   169  type ResourcePolicyArgs struct {
   170  	// Content for the resource policy. The text must be correctly formatted JSON that complies with the syntax for the resource policy's type. See the [_AWS Organizations User Guide_](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_delegate_examples.html) for examples.
   171  	Content pulumi.StringInput
   172  	// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   173  	Tags pulumi.StringMapInput
   174  }
   175  
   176  func (ResourcePolicyArgs) ElementType() reflect.Type {
   177  	return reflect.TypeOf((*resourcePolicyArgs)(nil)).Elem()
   178  }
   179  
   180  type ResourcePolicyInput interface {
   181  	pulumi.Input
   182  
   183  	ToResourcePolicyOutput() ResourcePolicyOutput
   184  	ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput
   185  }
   186  
   187  func (*ResourcePolicy) ElementType() reflect.Type {
   188  	return reflect.TypeOf((**ResourcePolicy)(nil)).Elem()
   189  }
   190  
   191  func (i *ResourcePolicy) ToResourcePolicyOutput() ResourcePolicyOutput {
   192  	return i.ToResourcePolicyOutputWithContext(context.Background())
   193  }
   194  
   195  func (i *ResourcePolicy) ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput {
   196  	return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyOutput)
   197  }
   198  
   199  // ResourcePolicyArrayInput is an input type that accepts ResourcePolicyArray and ResourcePolicyArrayOutput values.
   200  // You can construct a concrete instance of `ResourcePolicyArrayInput` via:
   201  //
   202  //	ResourcePolicyArray{ ResourcePolicyArgs{...} }
   203  type ResourcePolicyArrayInput interface {
   204  	pulumi.Input
   205  
   206  	ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput
   207  	ToResourcePolicyArrayOutputWithContext(context.Context) ResourcePolicyArrayOutput
   208  }
   209  
   210  type ResourcePolicyArray []ResourcePolicyInput
   211  
   212  func (ResourcePolicyArray) ElementType() reflect.Type {
   213  	return reflect.TypeOf((*[]*ResourcePolicy)(nil)).Elem()
   214  }
   215  
   216  func (i ResourcePolicyArray) ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput {
   217  	return i.ToResourcePolicyArrayOutputWithContext(context.Background())
   218  }
   219  
   220  func (i ResourcePolicyArray) ToResourcePolicyArrayOutputWithContext(ctx context.Context) ResourcePolicyArrayOutput {
   221  	return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyArrayOutput)
   222  }
   223  
   224  // ResourcePolicyMapInput is an input type that accepts ResourcePolicyMap and ResourcePolicyMapOutput values.
   225  // You can construct a concrete instance of `ResourcePolicyMapInput` via:
   226  //
   227  //	ResourcePolicyMap{ "key": ResourcePolicyArgs{...} }
   228  type ResourcePolicyMapInput interface {
   229  	pulumi.Input
   230  
   231  	ToResourcePolicyMapOutput() ResourcePolicyMapOutput
   232  	ToResourcePolicyMapOutputWithContext(context.Context) ResourcePolicyMapOutput
   233  }
   234  
   235  type ResourcePolicyMap map[string]ResourcePolicyInput
   236  
   237  func (ResourcePolicyMap) ElementType() reflect.Type {
   238  	return reflect.TypeOf((*map[string]*ResourcePolicy)(nil)).Elem()
   239  }
   240  
   241  func (i ResourcePolicyMap) ToResourcePolicyMapOutput() ResourcePolicyMapOutput {
   242  	return i.ToResourcePolicyMapOutputWithContext(context.Background())
   243  }
   244  
   245  func (i ResourcePolicyMap) ToResourcePolicyMapOutputWithContext(ctx context.Context) ResourcePolicyMapOutput {
   246  	return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyMapOutput)
   247  }
   248  
   249  type ResourcePolicyOutput struct{ *pulumi.OutputState }
   250  
   251  func (ResourcePolicyOutput) ElementType() reflect.Type {
   252  	return reflect.TypeOf((**ResourcePolicy)(nil)).Elem()
   253  }
   254  
   255  func (o ResourcePolicyOutput) ToResourcePolicyOutput() ResourcePolicyOutput {
   256  	return o
   257  }
   258  
   259  func (o ResourcePolicyOutput) ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput {
   260  	return o
   261  }
   262  
   263  // Amazon Resource Name (ARN) of the resource policy.
   264  func (o ResourcePolicyOutput) Arn() pulumi.StringOutput {
   265  	return o.ApplyT(func(v *ResourcePolicy) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   266  }
   267  
   268  // Content for the resource policy. The text must be correctly formatted JSON that complies with the syntax for the resource policy's type. See the [_AWS Organizations User Guide_](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_delegate_examples.html) for examples.
   269  func (o ResourcePolicyOutput) Content() pulumi.StringOutput {
   270  	return o.ApplyT(func(v *ResourcePolicy) pulumi.StringOutput { return v.Content }).(pulumi.StringOutput)
   271  }
   272  
   273  // Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   274  func (o ResourcePolicyOutput) Tags() pulumi.StringMapOutput {
   275  	return o.ApplyT(func(v *ResourcePolicy) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   276  }
   277  
   278  // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   279  //
   280  // Deprecated: Please use `tags` instead.
   281  func (o ResourcePolicyOutput) TagsAll() pulumi.StringMapOutput {
   282  	return o.ApplyT(func(v *ResourcePolicy) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   283  }
   284  
   285  type ResourcePolicyArrayOutput struct{ *pulumi.OutputState }
   286  
   287  func (ResourcePolicyArrayOutput) ElementType() reflect.Type {
   288  	return reflect.TypeOf((*[]*ResourcePolicy)(nil)).Elem()
   289  }
   290  
   291  func (o ResourcePolicyArrayOutput) ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput {
   292  	return o
   293  }
   294  
   295  func (o ResourcePolicyArrayOutput) ToResourcePolicyArrayOutputWithContext(ctx context.Context) ResourcePolicyArrayOutput {
   296  	return o
   297  }
   298  
   299  func (o ResourcePolicyArrayOutput) Index(i pulumi.IntInput) ResourcePolicyOutput {
   300  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ResourcePolicy {
   301  		return vs[0].([]*ResourcePolicy)[vs[1].(int)]
   302  	}).(ResourcePolicyOutput)
   303  }
   304  
   305  type ResourcePolicyMapOutput struct{ *pulumi.OutputState }
   306  
   307  func (ResourcePolicyMapOutput) ElementType() reflect.Type {
   308  	return reflect.TypeOf((*map[string]*ResourcePolicy)(nil)).Elem()
   309  }
   310  
   311  func (o ResourcePolicyMapOutput) ToResourcePolicyMapOutput() ResourcePolicyMapOutput {
   312  	return o
   313  }
   314  
   315  func (o ResourcePolicyMapOutput) ToResourcePolicyMapOutputWithContext(ctx context.Context) ResourcePolicyMapOutput {
   316  	return o
   317  }
   318  
   319  func (o ResourcePolicyMapOutput) MapIndex(k pulumi.StringInput) ResourcePolicyOutput {
   320  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ResourcePolicy {
   321  		return vs[0].(map[string]*ResourcePolicy)[vs[1].(string)]
   322  	}).(ResourcePolicyOutput)
   323  }
   324  
   325  func init() {
   326  	pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyInput)(nil)).Elem(), &ResourcePolicy{})
   327  	pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyArrayInput)(nil)).Elem(), ResourcePolicyArray{})
   328  	pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyMapInput)(nil)).Elem(), ResourcePolicyMap{})
   329  	pulumi.RegisterOutputType(ResourcePolicyOutput{})
   330  	pulumi.RegisterOutputType(ResourcePolicyArrayOutput{})
   331  	pulumi.RegisterOutputType(ResourcePolicyMapOutput{})
   332  }