github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/networkfirewall/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 networkfirewall
     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 an AWS Network Firewall Resource Policy Resource for a rule group or firewall policy.
    16  //
    17  // ## Example Usage
    18  //
    19  // ### For a Firewall Policy resource
    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/networkfirewall"
    30  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			tmpJSON0, err := json.Marshal(map[string]interface{}{
    37  //				"Statement": []map[string]interface{}{
    38  //					map[string]interface{}{
    39  //						"Action": []string{
    40  //							"network-firewall:ListFirewallPolicies",
    41  //							"network-firewall:CreateFirewall",
    42  //							"network-firewall:UpdateFirewall",
    43  //							"network-firewall:AssociateFirewallPolicy",
    44  //						},
    45  //						"Effect":   "Allow",
    46  //						"Resource": exampleAwsNetworkfirewallFirewallPolicy.Arn,
    47  //						"Principal": map[string]interface{}{
    48  //							"AWS": "arn:aws:iam::123456789012:root",
    49  //						},
    50  //					},
    51  //				},
    52  //				"Version": "2012-10-17",
    53  //			})
    54  //			if err != nil {
    55  //				return err
    56  //			}
    57  //			json0 := string(tmpJSON0)
    58  //			_, err = networkfirewall.NewResourcePolicy(ctx, "example", &networkfirewall.ResourcePolicyArgs{
    59  //				ResourceArn: pulumi.Any(exampleAwsNetworkfirewallFirewallPolicy.Arn),
    60  //				Policy:      pulumi.String(json0),
    61  //			})
    62  //			if err != nil {
    63  //				return err
    64  //			}
    65  //			return nil
    66  //		})
    67  //	}
    68  //
    69  // ```
    70  // <!--End PulumiCodeChooser -->
    71  //
    72  // ### For a Rule Group resource
    73  //
    74  // <!--Start PulumiCodeChooser -->
    75  // ```go
    76  // package main
    77  //
    78  // import (
    79  //
    80  //	"encoding/json"
    81  //
    82  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/networkfirewall"
    83  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    84  //
    85  // )
    86  //
    87  //	func main() {
    88  //		pulumi.Run(func(ctx *pulumi.Context) error {
    89  //			tmpJSON0, err := json.Marshal(map[string]interface{}{
    90  //				"Statement": []map[string]interface{}{
    91  //					map[string]interface{}{
    92  //						"Action": []string{
    93  //							"network-firewall:ListRuleGroups",
    94  //							"network-firewall:CreateFirewallPolicy",
    95  //							"network-firewall:UpdateFirewallPolicy",
    96  //						},
    97  //						"Effect":   "Allow",
    98  //						"Resource": exampleAwsNetworkfirewallRuleGroup.Arn,
    99  //						"Principal": map[string]interface{}{
   100  //							"AWS": "arn:aws:iam::123456789012:root",
   101  //						},
   102  //					},
   103  //				},
   104  //				"Version": "2012-10-17",
   105  //			})
   106  //			if err != nil {
   107  //				return err
   108  //			}
   109  //			json0 := string(tmpJSON0)
   110  //			_, err = networkfirewall.NewResourcePolicy(ctx, "example", &networkfirewall.ResourcePolicyArgs{
   111  //				ResourceArn: pulumi.Any(exampleAwsNetworkfirewallRuleGroup.Arn),
   112  //				Policy:      pulumi.String(json0),
   113  //			})
   114  //			if err != nil {
   115  //				return err
   116  //			}
   117  //			return nil
   118  //		})
   119  //	}
   120  //
   121  // ```
   122  // <!--End PulumiCodeChooser -->
   123  //
   124  // ## Import
   125  //
   126  // Using `pulumi import`, import Network Firewall Resource Policies using the `resource arn`. For example:
   127  // ```sh
   128  // $ pulumi import aws:networkfirewall/resourcePolicy:ResourcePolicy example arn:aws:network-firewall:us-west-1:123456789012:stateful-rulegroup/example
   129  // ```
   130  type ResourcePolicy struct {
   131  	pulumi.CustomResourceState
   132  
   133  	// JSON formatted policy document that controls access to the Network Firewall resource. The policy must be provided **without whitespaces**.  We recommend using jsonencode for formatting as seen in the examples above. For more details, including available policy statement Actions, see the [Policy](https://docs.aws.amazon.com/network-firewall/latest/APIReference/API_PutResourcePolicy.html#API_PutResourcePolicy_RequestSyntax) parameter in the AWS API documentation.
   134  	Policy pulumi.StringOutput `pulumi:"policy"`
   135  	// The Amazon Resource Name (ARN) of the rule group or firewall policy.
   136  	ResourceArn pulumi.StringOutput `pulumi:"resourceArn"`
   137  }
   138  
   139  // NewResourcePolicy registers a new resource with the given unique name, arguments, and options.
   140  func NewResourcePolicy(ctx *pulumi.Context,
   141  	name string, args *ResourcePolicyArgs, opts ...pulumi.ResourceOption) (*ResourcePolicy, error) {
   142  	if args == nil {
   143  		return nil, errors.New("missing one or more required arguments")
   144  	}
   145  
   146  	if args.Policy == nil {
   147  		return nil, errors.New("invalid value for required argument 'Policy'")
   148  	}
   149  	if args.ResourceArn == nil {
   150  		return nil, errors.New("invalid value for required argument 'ResourceArn'")
   151  	}
   152  	opts = internal.PkgResourceDefaultOpts(opts)
   153  	var resource ResourcePolicy
   154  	err := ctx.RegisterResource("aws:networkfirewall/resourcePolicy:ResourcePolicy", name, args, &resource, opts...)
   155  	if err != nil {
   156  		return nil, err
   157  	}
   158  	return &resource, nil
   159  }
   160  
   161  // GetResourcePolicy gets an existing ResourcePolicy resource's state with the given name, ID, and optional
   162  // state properties that are used to uniquely qualify the lookup (nil if not required).
   163  func GetResourcePolicy(ctx *pulumi.Context,
   164  	name string, id pulumi.IDInput, state *ResourcePolicyState, opts ...pulumi.ResourceOption) (*ResourcePolicy, error) {
   165  	var resource ResourcePolicy
   166  	err := ctx.ReadResource("aws:networkfirewall/resourcePolicy:ResourcePolicy", name, id, state, &resource, opts...)
   167  	if err != nil {
   168  		return nil, err
   169  	}
   170  	return &resource, nil
   171  }
   172  
   173  // Input properties used for looking up and filtering ResourcePolicy resources.
   174  type resourcePolicyState struct {
   175  	// JSON formatted policy document that controls access to the Network Firewall resource. The policy must be provided **without whitespaces**.  We recommend using jsonencode for formatting as seen in the examples above. For more details, including available policy statement Actions, see the [Policy](https://docs.aws.amazon.com/network-firewall/latest/APIReference/API_PutResourcePolicy.html#API_PutResourcePolicy_RequestSyntax) parameter in the AWS API documentation.
   176  	Policy *string `pulumi:"policy"`
   177  	// The Amazon Resource Name (ARN) of the rule group or firewall policy.
   178  	ResourceArn *string `pulumi:"resourceArn"`
   179  }
   180  
   181  type ResourcePolicyState struct {
   182  	// JSON formatted policy document that controls access to the Network Firewall resource. The policy must be provided **without whitespaces**.  We recommend using jsonencode for formatting as seen in the examples above. For more details, including available policy statement Actions, see the [Policy](https://docs.aws.amazon.com/network-firewall/latest/APIReference/API_PutResourcePolicy.html#API_PutResourcePolicy_RequestSyntax) parameter in the AWS API documentation.
   183  	Policy pulumi.StringPtrInput
   184  	// The Amazon Resource Name (ARN) of the rule group or firewall policy.
   185  	ResourceArn pulumi.StringPtrInput
   186  }
   187  
   188  func (ResourcePolicyState) ElementType() reflect.Type {
   189  	return reflect.TypeOf((*resourcePolicyState)(nil)).Elem()
   190  }
   191  
   192  type resourcePolicyArgs struct {
   193  	// JSON formatted policy document that controls access to the Network Firewall resource. The policy must be provided **without whitespaces**.  We recommend using jsonencode for formatting as seen in the examples above. For more details, including available policy statement Actions, see the [Policy](https://docs.aws.amazon.com/network-firewall/latest/APIReference/API_PutResourcePolicy.html#API_PutResourcePolicy_RequestSyntax) parameter in the AWS API documentation.
   194  	Policy string `pulumi:"policy"`
   195  	// The Amazon Resource Name (ARN) of the rule group or firewall policy.
   196  	ResourceArn string `pulumi:"resourceArn"`
   197  }
   198  
   199  // The set of arguments for constructing a ResourcePolicy resource.
   200  type ResourcePolicyArgs struct {
   201  	// JSON formatted policy document that controls access to the Network Firewall resource. The policy must be provided **without whitespaces**.  We recommend using jsonencode for formatting as seen in the examples above. For more details, including available policy statement Actions, see the [Policy](https://docs.aws.amazon.com/network-firewall/latest/APIReference/API_PutResourcePolicy.html#API_PutResourcePolicy_RequestSyntax) parameter in the AWS API documentation.
   202  	Policy pulumi.StringInput
   203  	// The Amazon Resource Name (ARN) of the rule group or firewall policy.
   204  	ResourceArn pulumi.StringInput
   205  }
   206  
   207  func (ResourcePolicyArgs) ElementType() reflect.Type {
   208  	return reflect.TypeOf((*resourcePolicyArgs)(nil)).Elem()
   209  }
   210  
   211  type ResourcePolicyInput interface {
   212  	pulumi.Input
   213  
   214  	ToResourcePolicyOutput() ResourcePolicyOutput
   215  	ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput
   216  }
   217  
   218  func (*ResourcePolicy) ElementType() reflect.Type {
   219  	return reflect.TypeOf((**ResourcePolicy)(nil)).Elem()
   220  }
   221  
   222  func (i *ResourcePolicy) ToResourcePolicyOutput() ResourcePolicyOutput {
   223  	return i.ToResourcePolicyOutputWithContext(context.Background())
   224  }
   225  
   226  func (i *ResourcePolicy) ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput {
   227  	return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyOutput)
   228  }
   229  
   230  // ResourcePolicyArrayInput is an input type that accepts ResourcePolicyArray and ResourcePolicyArrayOutput values.
   231  // You can construct a concrete instance of `ResourcePolicyArrayInput` via:
   232  //
   233  //	ResourcePolicyArray{ ResourcePolicyArgs{...} }
   234  type ResourcePolicyArrayInput interface {
   235  	pulumi.Input
   236  
   237  	ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput
   238  	ToResourcePolicyArrayOutputWithContext(context.Context) ResourcePolicyArrayOutput
   239  }
   240  
   241  type ResourcePolicyArray []ResourcePolicyInput
   242  
   243  func (ResourcePolicyArray) ElementType() reflect.Type {
   244  	return reflect.TypeOf((*[]*ResourcePolicy)(nil)).Elem()
   245  }
   246  
   247  func (i ResourcePolicyArray) ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput {
   248  	return i.ToResourcePolicyArrayOutputWithContext(context.Background())
   249  }
   250  
   251  func (i ResourcePolicyArray) ToResourcePolicyArrayOutputWithContext(ctx context.Context) ResourcePolicyArrayOutput {
   252  	return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyArrayOutput)
   253  }
   254  
   255  // ResourcePolicyMapInput is an input type that accepts ResourcePolicyMap and ResourcePolicyMapOutput values.
   256  // You can construct a concrete instance of `ResourcePolicyMapInput` via:
   257  //
   258  //	ResourcePolicyMap{ "key": ResourcePolicyArgs{...} }
   259  type ResourcePolicyMapInput interface {
   260  	pulumi.Input
   261  
   262  	ToResourcePolicyMapOutput() ResourcePolicyMapOutput
   263  	ToResourcePolicyMapOutputWithContext(context.Context) ResourcePolicyMapOutput
   264  }
   265  
   266  type ResourcePolicyMap map[string]ResourcePolicyInput
   267  
   268  func (ResourcePolicyMap) ElementType() reflect.Type {
   269  	return reflect.TypeOf((*map[string]*ResourcePolicy)(nil)).Elem()
   270  }
   271  
   272  func (i ResourcePolicyMap) ToResourcePolicyMapOutput() ResourcePolicyMapOutput {
   273  	return i.ToResourcePolicyMapOutputWithContext(context.Background())
   274  }
   275  
   276  func (i ResourcePolicyMap) ToResourcePolicyMapOutputWithContext(ctx context.Context) ResourcePolicyMapOutput {
   277  	return pulumi.ToOutputWithContext(ctx, i).(ResourcePolicyMapOutput)
   278  }
   279  
   280  type ResourcePolicyOutput struct{ *pulumi.OutputState }
   281  
   282  func (ResourcePolicyOutput) ElementType() reflect.Type {
   283  	return reflect.TypeOf((**ResourcePolicy)(nil)).Elem()
   284  }
   285  
   286  func (o ResourcePolicyOutput) ToResourcePolicyOutput() ResourcePolicyOutput {
   287  	return o
   288  }
   289  
   290  func (o ResourcePolicyOutput) ToResourcePolicyOutputWithContext(ctx context.Context) ResourcePolicyOutput {
   291  	return o
   292  }
   293  
   294  // JSON formatted policy document that controls access to the Network Firewall resource. The policy must be provided **without whitespaces**.  We recommend using jsonencode for formatting as seen in the examples above. For more details, including available policy statement Actions, see the [Policy](https://docs.aws.amazon.com/network-firewall/latest/APIReference/API_PutResourcePolicy.html#API_PutResourcePolicy_RequestSyntax) parameter in the AWS API documentation.
   295  func (o ResourcePolicyOutput) Policy() pulumi.StringOutput {
   296  	return o.ApplyT(func(v *ResourcePolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)
   297  }
   298  
   299  // The Amazon Resource Name (ARN) of the rule group or firewall policy.
   300  func (o ResourcePolicyOutput) ResourceArn() pulumi.StringOutput {
   301  	return o.ApplyT(func(v *ResourcePolicy) pulumi.StringOutput { return v.ResourceArn }).(pulumi.StringOutput)
   302  }
   303  
   304  type ResourcePolicyArrayOutput struct{ *pulumi.OutputState }
   305  
   306  func (ResourcePolicyArrayOutput) ElementType() reflect.Type {
   307  	return reflect.TypeOf((*[]*ResourcePolicy)(nil)).Elem()
   308  }
   309  
   310  func (o ResourcePolicyArrayOutput) ToResourcePolicyArrayOutput() ResourcePolicyArrayOutput {
   311  	return o
   312  }
   313  
   314  func (o ResourcePolicyArrayOutput) ToResourcePolicyArrayOutputWithContext(ctx context.Context) ResourcePolicyArrayOutput {
   315  	return o
   316  }
   317  
   318  func (o ResourcePolicyArrayOutput) Index(i pulumi.IntInput) ResourcePolicyOutput {
   319  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ResourcePolicy {
   320  		return vs[0].([]*ResourcePolicy)[vs[1].(int)]
   321  	}).(ResourcePolicyOutput)
   322  }
   323  
   324  type ResourcePolicyMapOutput struct{ *pulumi.OutputState }
   325  
   326  func (ResourcePolicyMapOutput) ElementType() reflect.Type {
   327  	return reflect.TypeOf((*map[string]*ResourcePolicy)(nil)).Elem()
   328  }
   329  
   330  func (o ResourcePolicyMapOutput) ToResourcePolicyMapOutput() ResourcePolicyMapOutput {
   331  	return o
   332  }
   333  
   334  func (o ResourcePolicyMapOutput) ToResourcePolicyMapOutputWithContext(ctx context.Context) ResourcePolicyMapOutput {
   335  	return o
   336  }
   337  
   338  func (o ResourcePolicyMapOutput) MapIndex(k pulumi.StringInput) ResourcePolicyOutput {
   339  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ResourcePolicy {
   340  		return vs[0].(map[string]*ResourcePolicy)[vs[1].(string)]
   341  	}).(ResourcePolicyOutput)
   342  }
   343  
   344  func init() {
   345  	pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyInput)(nil)).Elem(), &ResourcePolicy{})
   346  	pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyArrayInput)(nil)).Elem(), ResourcePolicyArray{})
   347  	pulumi.RegisterInputType(reflect.TypeOf((*ResourcePolicyMapInput)(nil)).Elem(), ResourcePolicyMap{})
   348  	pulumi.RegisterOutputType(ResourcePolicyOutput{})
   349  	pulumi.RegisterOutputType(ResourcePolicyArrayOutput{})
   350  	pulumi.RegisterOutputType(ResourcePolicyMapOutput{})
   351  }