github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/organizations/policy.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 an [AWS Organizations policy](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies.html). 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/iam" 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/organizations" 27 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 28 // 29 // ) 30 // 31 // func main() { 32 // pulumi.Run(func(ctx *pulumi.Context) error { 33 // example, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ 34 // Statements: []iam.GetPolicyDocumentStatement{ 35 // { 36 // Effect: pulumi.StringRef("Allow"), 37 // Actions: []string{ 38 // "*", 39 // }, 40 // Resources: []string{ 41 // "*", 42 // }, 43 // }, 44 // }, 45 // }, nil) 46 // if err != nil { 47 // return err 48 // } 49 // _, err = organizations.NewPolicy(ctx, "example", &organizations.PolicyArgs{ 50 // Name: pulumi.String("example"), 51 // Content: pulumi.String(example.Json), 52 // }) 53 // if err != nil { 54 // return err 55 // } 56 // return nil 57 // }) 58 // } 59 // 60 // ``` 61 // <!--End PulumiCodeChooser --> 62 // 63 // ## Import 64 // 65 // Using `pulumi import`, import `aws_organizations_policy` using the policy ID. For example: 66 // 67 // ```sh 68 // $ pulumi import aws:organizations/policy:Policy example p-12345678 69 // ``` 70 type Policy struct { 71 pulumi.CustomResourceState 72 73 // Amazon Resource Name (ARN) of the policy. 74 Arn pulumi.StringOutput `pulumi:"arn"` 75 // The policy content to add to the new policy. For example, if you create a [service control policy (SCP)](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scp.html), this string must be JSON text that specifies the permissions that admins in attached accounts can delegate to their users, groups, and roles. For more information about the SCP syntax, see the [Service Control Policy Syntax documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_reference_scp-syntax.html) and for more information on the Tag Policy syntax, see the [Tag Policy Syntax documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_example-tag-policies.html). 76 Content pulumi.StringOutput `pulumi:"content"` 77 // A description to assign to the policy. 78 Description pulumi.StringPtrOutput `pulumi:"description"` 79 // The friendly name to assign to the policy. 80 Name pulumi.StringOutput `pulumi:"name"` 81 // If set to `true`, destroy will **not** delete the policy and instead just remove the resource from state. This can be useful in situations where the policies (and the associated attachment) must be preserved to meet the AWS minimum requirement of 1 attached policy. 82 SkipDestroy pulumi.BoolPtrOutput `pulumi:"skipDestroy"` 83 // 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. 84 Tags pulumi.StringMapOutput `pulumi:"tags"` 85 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 86 // 87 // Deprecated: Please use `tags` instead. 88 TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"` 89 // The type of policy to create. Valid values are `AISERVICES_OPT_OUT_POLICY`, `BACKUP_POLICY`, `SERVICE_CONTROL_POLICY` (SCP), and `TAG_POLICY`. Defaults to `SERVICE_CONTROL_POLICY`. 90 Type pulumi.StringPtrOutput `pulumi:"type"` 91 } 92 93 // NewPolicy registers a new resource with the given unique name, arguments, and options. 94 func NewPolicy(ctx *pulumi.Context, 95 name string, args *PolicyArgs, opts ...pulumi.ResourceOption) (*Policy, error) { 96 if args == nil { 97 return nil, errors.New("missing one or more required arguments") 98 } 99 100 if args.Content == nil { 101 return nil, errors.New("invalid value for required argument 'Content'") 102 } 103 opts = internal.PkgResourceDefaultOpts(opts) 104 var resource Policy 105 err := ctx.RegisterResource("aws:organizations/policy:Policy", name, args, &resource, opts...) 106 if err != nil { 107 return nil, err 108 } 109 return &resource, nil 110 } 111 112 // GetPolicy gets an existing Policy resource's state with the given name, ID, and optional 113 // state properties that are used to uniquely qualify the lookup (nil if not required). 114 func GetPolicy(ctx *pulumi.Context, 115 name string, id pulumi.IDInput, state *PolicyState, opts ...pulumi.ResourceOption) (*Policy, error) { 116 var resource Policy 117 err := ctx.ReadResource("aws:organizations/policy:Policy", name, id, state, &resource, opts...) 118 if err != nil { 119 return nil, err 120 } 121 return &resource, nil 122 } 123 124 // Input properties used for looking up and filtering Policy resources. 125 type policyState struct { 126 // Amazon Resource Name (ARN) of the policy. 127 Arn *string `pulumi:"arn"` 128 // The policy content to add to the new policy. For example, if you create a [service control policy (SCP)](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scp.html), this string must be JSON text that specifies the permissions that admins in attached accounts can delegate to their users, groups, and roles. For more information about the SCP syntax, see the [Service Control Policy Syntax documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_reference_scp-syntax.html) and for more information on the Tag Policy syntax, see the [Tag Policy Syntax documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_example-tag-policies.html). 129 Content *string `pulumi:"content"` 130 // A description to assign to the policy. 131 Description *string `pulumi:"description"` 132 // The friendly name to assign to the policy. 133 Name *string `pulumi:"name"` 134 // If set to `true`, destroy will **not** delete the policy and instead just remove the resource from state. This can be useful in situations where the policies (and the associated attachment) must be preserved to meet the AWS minimum requirement of 1 attached policy. 135 SkipDestroy *bool `pulumi:"skipDestroy"` 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 // The type of policy to create. Valid values are `AISERVICES_OPT_OUT_POLICY`, `BACKUP_POLICY`, `SERVICE_CONTROL_POLICY` (SCP), and `TAG_POLICY`. Defaults to `SERVICE_CONTROL_POLICY`. 143 Type *string `pulumi:"type"` 144 } 145 146 type PolicyState struct { 147 // Amazon Resource Name (ARN) of the policy. 148 Arn pulumi.StringPtrInput 149 // The policy content to add to the new policy. For example, if you create a [service control policy (SCP)](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scp.html), this string must be JSON text that specifies the permissions that admins in attached accounts can delegate to their users, groups, and roles. For more information about the SCP syntax, see the [Service Control Policy Syntax documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_reference_scp-syntax.html) and for more information on the Tag Policy syntax, see the [Tag Policy Syntax documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_example-tag-policies.html). 150 Content pulumi.StringPtrInput 151 // A description to assign to the policy. 152 Description pulumi.StringPtrInput 153 // The friendly name to assign to the policy. 154 Name pulumi.StringPtrInput 155 // If set to `true`, destroy will **not** delete the policy and instead just remove the resource from state. This can be useful in situations where the policies (and the associated attachment) must be preserved to meet the AWS minimum requirement of 1 attached policy. 156 SkipDestroy pulumi.BoolPtrInput 157 // 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. 158 Tags pulumi.StringMapInput 159 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 160 // 161 // Deprecated: Please use `tags` instead. 162 TagsAll pulumi.StringMapInput 163 // The type of policy to create. Valid values are `AISERVICES_OPT_OUT_POLICY`, `BACKUP_POLICY`, `SERVICE_CONTROL_POLICY` (SCP), and `TAG_POLICY`. Defaults to `SERVICE_CONTROL_POLICY`. 164 Type pulumi.StringPtrInput 165 } 166 167 func (PolicyState) ElementType() reflect.Type { 168 return reflect.TypeOf((*policyState)(nil)).Elem() 169 } 170 171 type policyArgs struct { 172 // The policy content to add to the new policy. For example, if you create a [service control policy (SCP)](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scp.html), this string must be JSON text that specifies the permissions that admins in attached accounts can delegate to their users, groups, and roles. For more information about the SCP syntax, see the [Service Control Policy Syntax documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_reference_scp-syntax.html) and for more information on the Tag Policy syntax, see the [Tag Policy Syntax documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_example-tag-policies.html). 173 Content string `pulumi:"content"` 174 // A description to assign to the policy. 175 Description *string `pulumi:"description"` 176 // The friendly name to assign to the policy. 177 Name *string `pulumi:"name"` 178 // If set to `true`, destroy will **not** delete the policy and instead just remove the resource from state. This can be useful in situations where the policies (and the associated attachment) must be preserved to meet the AWS minimum requirement of 1 attached policy. 179 SkipDestroy *bool `pulumi:"skipDestroy"` 180 // 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. 181 Tags map[string]string `pulumi:"tags"` 182 // The type of policy to create. Valid values are `AISERVICES_OPT_OUT_POLICY`, `BACKUP_POLICY`, `SERVICE_CONTROL_POLICY` (SCP), and `TAG_POLICY`. Defaults to `SERVICE_CONTROL_POLICY`. 183 Type *string `pulumi:"type"` 184 } 185 186 // The set of arguments for constructing a Policy resource. 187 type PolicyArgs struct { 188 // The policy content to add to the new policy. For example, if you create a [service control policy (SCP)](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scp.html), this string must be JSON text that specifies the permissions that admins in attached accounts can delegate to their users, groups, and roles. For more information about the SCP syntax, see the [Service Control Policy Syntax documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_reference_scp-syntax.html) and for more information on the Tag Policy syntax, see the [Tag Policy Syntax documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_example-tag-policies.html). 189 Content pulumi.StringInput 190 // A description to assign to the policy. 191 Description pulumi.StringPtrInput 192 // The friendly name to assign to the policy. 193 Name pulumi.StringPtrInput 194 // If set to `true`, destroy will **not** delete the policy and instead just remove the resource from state. This can be useful in situations where the policies (and the associated attachment) must be preserved to meet the AWS minimum requirement of 1 attached policy. 195 SkipDestroy pulumi.BoolPtrInput 196 // 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. 197 Tags pulumi.StringMapInput 198 // The type of policy to create. Valid values are `AISERVICES_OPT_OUT_POLICY`, `BACKUP_POLICY`, `SERVICE_CONTROL_POLICY` (SCP), and `TAG_POLICY`. Defaults to `SERVICE_CONTROL_POLICY`. 199 Type pulumi.StringPtrInput 200 } 201 202 func (PolicyArgs) ElementType() reflect.Type { 203 return reflect.TypeOf((*policyArgs)(nil)).Elem() 204 } 205 206 type PolicyInput interface { 207 pulumi.Input 208 209 ToPolicyOutput() PolicyOutput 210 ToPolicyOutputWithContext(ctx context.Context) PolicyOutput 211 } 212 213 func (*Policy) ElementType() reflect.Type { 214 return reflect.TypeOf((**Policy)(nil)).Elem() 215 } 216 217 func (i *Policy) ToPolicyOutput() PolicyOutput { 218 return i.ToPolicyOutputWithContext(context.Background()) 219 } 220 221 func (i *Policy) ToPolicyOutputWithContext(ctx context.Context) PolicyOutput { 222 return pulumi.ToOutputWithContext(ctx, i).(PolicyOutput) 223 } 224 225 // PolicyArrayInput is an input type that accepts PolicyArray and PolicyArrayOutput values. 226 // You can construct a concrete instance of `PolicyArrayInput` via: 227 // 228 // PolicyArray{ PolicyArgs{...} } 229 type PolicyArrayInput interface { 230 pulumi.Input 231 232 ToPolicyArrayOutput() PolicyArrayOutput 233 ToPolicyArrayOutputWithContext(context.Context) PolicyArrayOutput 234 } 235 236 type PolicyArray []PolicyInput 237 238 func (PolicyArray) ElementType() reflect.Type { 239 return reflect.TypeOf((*[]*Policy)(nil)).Elem() 240 } 241 242 func (i PolicyArray) ToPolicyArrayOutput() PolicyArrayOutput { 243 return i.ToPolicyArrayOutputWithContext(context.Background()) 244 } 245 246 func (i PolicyArray) ToPolicyArrayOutputWithContext(ctx context.Context) PolicyArrayOutput { 247 return pulumi.ToOutputWithContext(ctx, i).(PolicyArrayOutput) 248 } 249 250 // PolicyMapInput is an input type that accepts PolicyMap and PolicyMapOutput values. 251 // You can construct a concrete instance of `PolicyMapInput` via: 252 // 253 // PolicyMap{ "key": PolicyArgs{...} } 254 type PolicyMapInput interface { 255 pulumi.Input 256 257 ToPolicyMapOutput() PolicyMapOutput 258 ToPolicyMapOutputWithContext(context.Context) PolicyMapOutput 259 } 260 261 type PolicyMap map[string]PolicyInput 262 263 func (PolicyMap) ElementType() reflect.Type { 264 return reflect.TypeOf((*map[string]*Policy)(nil)).Elem() 265 } 266 267 func (i PolicyMap) ToPolicyMapOutput() PolicyMapOutput { 268 return i.ToPolicyMapOutputWithContext(context.Background()) 269 } 270 271 func (i PolicyMap) ToPolicyMapOutputWithContext(ctx context.Context) PolicyMapOutput { 272 return pulumi.ToOutputWithContext(ctx, i).(PolicyMapOutput) 273 } 274 275 type PolicyOutput struct{ *pulumi.OutputState } 276 277 func (PolicyOutput) ElementType() reflect.Type { 278 return reflect.TypeOf((**Policy)(nil)).Elem() 279 } 280 281 func (o PolicyOutput) ToPolicyOutput() PolicyOutput { 282 return o 283 } 284 285 func (o PolicyOutput) ToPolicyOutputWithContext(ctx context.Context) PolicyOutput { 286 return o 287 } 288 289 // Amazon Resource Name (ARN) of the policy. 290 func (o PolicyOutput) Arn() pulumi.StringOutput { 291 return o.ApplyT(func(v *Policy) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput) 292 } 293 294 // The policy content to add to the new policy. For example, if you create a [service control policy (SCP)](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scp.html), this string must be JSON text that specifies the permissions that admins in attached accounts can delegate to their users, groups, and roles. For more information about the SCP syntax, see the [Service Control Policy Syntax documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_reference_scp-syntax.html) and for more information on the Tag Policy syntax, see the [Tag Policy Syntax documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_example-tag-policies.html). 295 func (o PolicyOutput) Content() pulumi.StringOutput { 296 return o.ApplyT(func(v *Policy) pulumi.StringOutput { return v.Content }).(pulumi.StringOutput) 297 } 298 299 // A description to assign to the policy. 300 func (o PolicyOutput) Description() pulumi.StringPtrOutput { 301 return o.ApplyT(func(v *Policy) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput) 302 } 303 304 // The friendly name to assign to the policy. 305 func (o PolicyOutput) Name() pulumi.StringOutput { 306 return o.ApplyT(func(v *Policy) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput) 307 } 308 309 // If set to `true`, destroy will **not** delete the policy and instead just remove the resource from state. This can be useful in situations where the policies (and the associated attachment) must be preserved to meet the AWS minimum requirement of 1 attached policy. 310 func (o PolicyOutput) SkipDestroy() pulumi.BoolPtrOutput { 311 return o.ApplyT(func(v *Policy) pulumi.BoolPtrOutput { return v.SkipDestroy }).(pulumi.BoolPtrOutput) 312 } 313 314 // 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. 315 func (o PolicyOutput) Tags() pulumi.StringMapOutput { 316 return o.ApplyT(func(v *Policy) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput) 317 } 318 319 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 320 // 321 // Deprecated: Please use `tags` instead. 322 func (o PolicyOutput) TagsAll() pulumi.StringMapOutput { 323 return o.ApplyT(func(v *Policy) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput) 324 } 325 326 // The type of policy to create. Valid values are `AISERVICES_OPT_OUT_POLICY`, `BACKUP_POLICY`, `SERVICE_CONTROL_POLICY` (SCP), and `TAG_POLICY`. Defaults to `SERVICE_CONTROL_POLICY`. 327 func (o PolicyOutput) Type() pulumi.StringPtrOutput { 328 return o.ApplyT(func(v *Policy) pulumi.StringPtrOutput { return v.Type }).(pulumi.StringPtrOutput) 329 } 330 331 type PolicyArrayOutput struct{ *pulumi.OutputState } 332 333 func (PolicyArrayOutput) ElementType() reflect.Type { 334 return reflect.TypeOf((*[]*Policy)(nil)).Elem() 335 } 336 337 func (o PolicyArrayOutput) ToPolicyArrayOutput() PolicyArrayOutput { 338 return o 339 } 340 341 func (o PolicyArrayOutput) ToPolicyArrayOutputWithContext(ctx context.Context) PolicyArrayOutput { 342 return o 343 } 344 345 func (o PolicyArrayOutput) Index(i pulumi.IntInput) PolicyOutput { 346 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Policy { 347 return vs[0].([]*Policy)[vs[1].(int)] 348 }).(PolicyOutput) 349 } 350 351 type PolicyMapOutput struct{ *pulumi.OutputState } 352 353 func (PolicyMapOutput) ElementType() reflect.Type { 354 return reflect.TypeOf((*map[string]*Policy)(nil)).Elem() 355 } 356 357 func (o PolicyMapOutput) ToPolicyMapOutput() PolicyMapOutput { 358 return o 359 } 360 361 func (o PolicyMapOutput) ToPolicyMapOutputWithContext(ctx context.Context) PolicyMapOutput { 362 return o 363 } 364 365 func (o PolicyMapOutput) MapIndex(k pulumi.StringInput) PolicyOutput { 366 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Policy { 367 return vs[0].(map[string]*Policy)[vs[1].(string)] 368 }).(PolicyOutput) 369 } 370 371 func init() { 372 pulumi.RegisterInputType(reflect.TypeOf((*PolicyInput)(nil)).Elem(), &Policy{}) 373 pulumi.RegisterInputType(reflect.TypeOf((*PolicyArrayInput)(nil)).Elem(), PolicyArray{}) 374 pulumi.RegisterInputType(reflect.TypeOf((*PolicyMapInput)(nil)).Elem(), PolicyMap{}) 375 pulumi.RegisterOutputType(PolicyOutput{}) 376 pulumi.RegisterOutputType(PolicyArrayOutput{}) 377 pulumi.RegisterOutputType(PolicyMapOutput{}) 378 }