github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/guardduty/ipset.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 guardduty
     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 GuardDuty IPSet.
    16  //
    17  // > **Note:** Currently in GuardDuty, users from member accounts cannot upload and further manage IPSets. IPSets that are uploaded by the primary account are imposed on GuardDuty functionality in its member accounts. See the [GuardDuty API Documentation](https://docs.aws.amazon.com/guardduty/latest/ug/create-ip-set.html)
    18  //
    19  // ## Example Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"fmt"
    28  //
    29  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/guardduty"
    30  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
    31  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    32  //
    33  // )
    34  //
    35  //	func main() {
    36  //		pulumi.Run(func(ctx *pulumi.Context) error {
    37  //			primary, err := guardduty.NewDetector(ctx, "primary", &guardduty.DetectorArgs{
    38  //				Enable: pulumi.Bool(true),
    39  //			})
    40  //			if err != nil {
    41  //				return err
    42  //			}
    43  //			bucket, err := s3.NewBucketV2(ctx, "bucket", nil)
    44  //			if err != nil {
    45  //				return err
    46  //			}
    47  //			myIPSet, err := s3.NewBucketObjectv2(ctx, "MyIPSet", &s3.BucketObjectv2Args{
    48  //				Content: pulumi.String("10.0.0.0/8\n"),
    49  //				Bucket:  bucket.ID(),
    50  //				Key:     pulumi.String("MyIPSet"),
    51  //			})
    52  //			if err != nil {
    53  //				return err
    54  //			}
    55  //			_, err = guardduty.NewIPSet(ctx, "example", &guardduty.IPSetArgs{
    56  //				Activate:   pulumi.Bool(true),
    57  //				DetectorId: primary.ID(),
    58  //				Format:     pulumi.String("TXT"),
    59  //				Location: pulumi.All(myIPSet.Bucket, myIPSet.Key).ApplyT(func(_args []interface{}) (string, error) {
    60  //					bucket := _args[0].(string)
    61  //					key := _args[1].(string)
    62  //					return fmt.Sprintf("https://s3.amazonaws.com/%v/%v", bucket, key), nil
    63  //				}).(pulumi.StringOutput),
    64  //				Name: pulumi.String("MyIPSet"),
    65  //			})
    66  //			if err != nil {
    67  //				return err
    68  //			}
    69  //			_, err = s3.NewBucketAclV2(ctx, "bucket_acl", &s3.BucketAclV2Args{
    70  //				Bucket: bucket.ID(),
    71  //				Acl:    pulumi.String("private"),
    72  //			})
    73  //			if err != nil {
    74  //				return err
    75  //			}
    76  //			return nil
    77  //		})
    78  //	}
    79  //
    80  // ```
    81  // <!--End PulumiCodeChooser -->
    82  //
    83  // ## Import
    84  //
    85  // Using `pulumi import`, import GuardDuty IPSet using the primary GuardDuty detector ID and IPSet ID. For example:
    86  //
    87  // ```sh
    88  // $ pulumi import aws:guardduty/iPSet:IPSet MyIPSet 00b00fd5aecc0ab60a708659477e9617:123456789012
    89  // ```
    90  type IPSet struct {
    91  	pulumi.CustomResourceState
    92  
    93  	// Specifies whether GuardDuty is to start using the uploaded IPSet.
    94  	Activate pulumi.BoolOutput `pulumi:"activate"`
    95  	// Amazon Resource Name (ARN) of the GuardDuty IPSet.
    96  	Arn pulumi.StringOutput `pulumi:"arn"`
    97  	// The detector ID of the GuardDuty.
    98  	DetectorId pulumi.StringOutput `pulumi:"detectorId"`
    99  	// The format of the file that contains the IPSet. Valid values: `TXT` | `STIX` | `OTX_CSV` | `ALIEN_VAULT` | `PROOF_POINT` | `FIRE_EYE`
   100  	Format pulumi.StringOutput `pulumi:"format"`
   101  	// The URI of the file that contains the IPSet.
   102  	Location pulumi.StringOutput `pulumi:"location"`
   103  	// The friendly name to identify the IPSet.
   104  	Name pulumi.StringOutput `pulumi:"name"`
   105  	// 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.
   106  	Tags pulumi.StringMapOutput `pulumi:"tags"`
   107  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   108  	//
   109  	// Deprecated: Please use `tags` instead.
   110  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
   111  }
   112  
   113  // NewIPSet registers a new resource with the given unique name, arguments, and options.
   114  func NewIPSet(ctx *pulumi.Context,
   115  	name string, args *IPSetArgs, opts ...pulumi.ResourceOption) (*IPSet, error) {
   116  	if args == nil {
   117  		return nil, errors.New("missing one or more required arguments")
   118  	}
   119  
   120  	if args.Activate == nil {
   121  		return nil, errors.New("invalid value for required argument 'Activate'")
   122  	}
   123  	if args.DetectorId == nil {
   124  		return nil, errors.New("invalid value for required argument 'DetectorId'")
   125  	}
   126  	if args.Format == nil {
   127  		return nil, errors.New("invalid value for required argument 'Format'")
   128  	}
   129  	if args.Location == nil {
   130  		return nil, errors.New("invalid value for required argument 'Location'")
   131  	}
   132  	opts = internal.PkgResourceDefaultOpts(opts)
   133  	var resource IPSet
   134  	err := ctx.RegisterResource("aws:guardduty/iPSet:IPSet", name, args, &resource, opts...)
   135  	if err != nil {
   136  		return nil, err
   137  	}
   138  	return &resource, nil
   139  }
   140  
   141  // GetIPSet gets an existing IPSet resource's state with the given name, ID, and optional
   142  // state properties that are used to uniquely qualify the lookup (nil if not required).
   143  func GetIPSet(ctx *pulumi.Context,
   144  	name string, id pulumi.IDInput, state *IPSetState, opts ...pulumi.ResourceOption) (*IPSet, error) {
   145  	var resource IPSet
   146  	err := ctx.ReadResource("aws:guardduty/iPSet:IPSet", name, id, state, &resource, opts...)
   147  	if err != nil {
   148  		return nil, err
   149  	}
   150  	return &resource, nil
   151  }
   152  
   153  // Input properties used for looking up and filtering IPSet resources.
   154  type ipsetState struct {
   155  	// Specifies whether GuardDuty is to start using the uploaded IPSet.
   156  	Activate *bool `pulumi:"activate"`
   157  	// Amazon Resource Name (ARN) of the GuardDuty IPSet.
   158  	Arn *string `pulumi:"arn"`
   159  	// The detector ID of the GuardDuty.
   160  	DetectorId *string `pulumi:"detectorId"`
   161  	// The format of the file that contains the IPSet. Valid values: `TXT` | `STIX` | `OTX_CSV` | `ALIEN_VAULT` | `PROOF_POINT` | `FIRE_EYE`
   162  	Format *string `pulumi:"format"`
   163  	// The URI of the file that contains the IPSet.
   164  	Location *string `pulumi:"location"`
   165  	// The friendly name to identify the IPSet.
   166  	Name *string `pulumi:"name"`
   167  	// 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.
   168  	Tags map[string]string `pulumi:"tags"`
   169  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   170  	//
   171  	// Deprecated: Please use `tags` instead.
   172  	TagsAll map[string]string `pulumi:"tagsAll"`
   173  }
   174  
   175  type IPSetState struct {
   176  	// Specifies whether GuardDuty is to start using the uploaded IPSet.
   177  	Activate pulumi.BoolPtrInput
   178  	// Amazon Resource Name (ARN) of the GuardDuty IPSet.
   179  	Arn pulumi.StringPtrInput
   180  	// The detector ID of the GuardDuty.
   181  	DetectorId pulumi.StringPtrInput
   182  	// The format of the file that contains the IPSet. Valid values: `TXT` | `STIX` | `OTX_CSV` | `ALIEN_VAULT` | `PROOF_POINT` | `FIRE_EYE`
   183  	Format pulumi.StringPtrInput
   184  	// The URI of the file that contains the IPSet.
   185  	Location pulumi.StringPtrInput
   186  	// The friendly name to identify the IPSet.
   187  	Name pulumi.StringPtrInput
   188  	// 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.
   189  	Tags pulumi.StringMapInput
   190  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   191  	//
   192  	// Deprecated: Please use `tags` instead.
   193  	TagsAll pulumi.StringMapInput
   194  }
   195  
   196  func (IPSetState) ElementType() reflect.Type {
   197  	return reflect.TypeOf((*ipsetState)(nil)).Elem()
   198  }
   199  
   200  type ipsetArgs struct {
   201  	// Specifies whether GuardDuty is to start using the uploaded IPSet.
   202  	Activate bool `pulumi:"activate"`
   203  	// The detector ID of the GuardDuty.
   204  	DetectorId string `pulumi:"detectorId"`
   205  	// The format of the file that contains the IPSet. Valid values: `TXT` | `STIX` | `OTX_CSV` | `ALIEN_VAULT` | `PROOF_POINT` | `FIRE_EYE`
   206  	Format string `pulumi:"format"`
   207  	// The URI of the file that contains the IPSet.
   208  	Location string `pulumi:"location"`
   209  	// The friendly name to identify the IPSet.
   210  	Name *string `pulumi:"name"`
   211  	// 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.
   212  	Tags map[string]string `pulumi:"tags"`
   213  }
   214  
   215  // The set of arguments for constructing a IPSet resource.
   216  type IPSetArgs struct {
   217  	// Specifies whether GuardDuty is to start using the uploaded IPSet.
   218  	Activate pulumi.BoolInput
   219  	// The detector ID of the GuardDuty.
   220  	DetectorId pulumi.StringInput
   221  	// The format of the file that contains the IPSet. Valid values: `TXT` | `STIX` | `OTX_CSV` | `ALIEN_VAULT` | `PROOF_POINT` | `FIRE_EYE`
   222  	Format pulumi.StringInput
   223  	// The URI of the file that contains the IPSet.
   224  	Location pulumi.StringInput
   225  	// The friendly name to identify the IPSet.
   226  	Name pulumi.StringPtrInput
   227  	// 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.
   228  	Tags pulumi.StringMapInput
   229  }
   230  
   231  func (IPSetArgs) ElementType() reflect.Type {
   232  	return reflect.TypeOf((*ipsetArgs)(nil)).Elem()
   233  }
   234  
   235  type IPSetInput interface {
   236  	pulumi.Input
   237  
   238  	ToIPSetOutput() IPSetOutput
   239  	ToIPSetOutputWithContext(ctx context.Context) IPSetOutput
   240  }
   241  
   242  func (*IPSet) ElementType() reflect.Type {
   243  	return reflect.TypeOf((**IPSet)(nil)).Elem()
   244  }
   245  
   246  func (i *IPSet) ToIPSetOutput() IPSetOutput {
   247  	return i.ToIPSetOutputWithContext(context.Background())
   248  }
   249  
   250  func (i *IPSet) ToIPSetOutputWithContext(ctx context.Context) IPSetOutput {
   251  	return pulumi.ToOutputWithContext(ctx, i).(IPSetOutput)
   252  }
   253  
   254  // IPSetArrayInput is an input type that accepts IPSetArray and IPSetArrayOutput values.
   255  // You can construct a concrete instance of `IPSetArrayInput` via:
   256  //
   257  //	IPSetArray{ IPSetArgs{...} }
   258  type IPSetArrayInput interface {
   259  	pulumi.Input
   260  
   261  	ToIPSetArrayOutput() IPSetArrayOutput
   262  	ToIPSetArrayOutputWithContext(context.Context) IPSetArrayOutput
   263  }
   264  
   265  type IPSetArray []IPSetInput
   266  
   267  func (IPSetArray) ElementType() reflect.Type {
   268  	return reflect.TypeOf((*[]*IPSet)(nil)).Elem()
   269  }
   270  
   271  func (i IPSetArray) ToIPSetArrayOutput() IPSetArrayOutput {
   272  	return i.ToIPSetArrayOutputWithContext(context.Background())
   273  }
   274  
   275  func (i IPSetArray) ToIPSetArrayOutputWithContext(ctx context.Context) IPSetArrayOutput {
   276  	return pulumi.ToOutputWithContext(ctx, i).(IPSetArrayOutput)
   277  }
   278  
   279  // IPSetMapInput is an input type that accepts IPSetMap and IPSetMapOutput values.
   280  // You can construct a concrete instance of `IPSetMapInput` via:
   281  //
   282  //	IPSetMap{ "key": IPSetArgs{...} }
   283  type IPSetMapInput interface {
   284  	pulumi.Input
   285  
   286  	ToIPSetMapOutput() IPSetMapOutput
   287  	ToIPSetMapOutputWithContext(context.Context) IPSetMapOutput
   288  }
   289  
   290  type IPSetMap map[string]IPSetInput
   291  
   292  func (IPSetMap) ElementType() reflect.Type {
   293  	return reflect.TypeOf((*map[string]*IPSet)(nil)).Elem()
   294  }
   295  
   296  func (i IPSetMap) ToIPSetMapOutput() IPSetMapOutput {
   297  	return i.ToIPSetMapOutputWithContext(context.Background())
   298  }
   299  
   300  func (i IPSetMap) ToIPSetMapOutputWithContext(ctx context.Context) IPSetMapOutput {
   301  	return pulumi.ToOutputWithContext(ctx, i).(IPSetMapOutput)
   302  }
   303  
   304  type IPSetOutput struct{ *pulumi.OutputState }
   305  
   306  func (IPSetOutput) ElementType() reflect.Type {
   307  	return reflect.TypeOf((**IPSet)(nil)).Elem()
   308  }
   309  
   310  func (o IPSetOutput) ToIPSetOutput() IPSetOutput {
   311  	return o
   312  }
   313  
   314  func (o IPSetOutput) ToIPSetOutputWithContext(ctx context.Context) IPSetOutput {
   315  	return o
   316  }
   317  
   318  // Specifies whether GuardDuty is to start using the uploaded IPSet.
   319  func (o IPSetOutput) Activate() pulumi.BoolOutput {
   320  	return o.ApplyT(func(v *IPSet) pulumi.BoolOutput { return v.Activate }).(pulumi.BoolOutput)
   321  }
   322  
   323  // Amazon Resource Name (ARN) of the GuardDuty IPSet.
   324  func (o IPSetOutput) Arn() pulumi.StringOutput {
   325  	return o.ApplyT(func(v *IPSet) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   326  }
   327  
   328  // The detector ID of the GuardDuty.
   329  func (o IPSetOutput) DetectorId() pulumi.StringOutput {
   330  	return o.ApplyT(func(v *IPSet) pulumi.StringOutput { return v.DetectorId }).(pulumi.StringOutput)
   331  }
   332  
   333  // The format of the file that contains the IPSet. Valid values: `TXT` | `STIX` | `OTX_CSV` | `ALIEN_VAULT` | `PROOF_POINT` | `FIRE_EYE`
   334  func (o IPSetOutput) Format() pulumi.StringOutput {
   335  	return o.ApplyT(func(v *IPSet) pulumi.StringOutput { return v.Format }).(pulumi.StringOutput)
   336  }
   337  
   338  // The URI of the file that contains the IPSet.
   339  func (o IPSetOutput) Location() pulumi.StringOutput {
   340  	return o.ApplyT(func(v *IPSet) pulumi.StringOutput { return v.Location }).(pulumi.StringOutput)
   341  }
   342  
   343  // The friendly name to identify the IPSet.
   344  func (o IPSetOutput) Name() pulumi.StringOutput {
   345  	return o.ApplyT(func(v *IPSet) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   346  }
   347  
   348  // 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.
   349  func (o IPSetOutput) Tags() pulumi.StringMapOutput {
   350  	return o.ApplyT(func(v *IPSet) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   351  }
   352  
   353  // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   354  //
   355  // Deprecated: Please use `tags` instead.
   356  func (o IPSetOutput) TagsAll() pulumi.StringMapOutput {
   357  	return o.ApplyT(func(v *IPSet) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   358  }
   359  
   360  type IPSetArrayOutput struct{ *pulumi.OutputState }
   361  
   362  func (IPSetArrayOutput) ElementType() reflect.Type {
   363  	return reflect.TypeOf((*[]*IPSet)(nil)).Elem()
   364  }
   365  
   366  func (o IPSetArrayOutput) ToIPSetArrayOutput() IPSetArrayOutput {
   367  	return o
   368  }
   369  
   370  func (o IPSetArrayOutput) ToIPSetArrayOutputWithContext(ctx context.Context) IPSetArrayOutput {
   371  	return o
   372  }
   373  
   374  func (o IPSetArrayOutput) Index(i pulumi.IntInput) IPSetOutput {
   375  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *IPSet {
   376  		return vs[0].([]*IPSet)[vs[1].(int)]
   377  	}).(IPSetOutput)
   378  }
   379  
   380  type IPSetMapOutput struct{ *pulumi.OutputState }
   381  
   382  func (IPSetMapOutput) ElementType() reflect.Type {
   383  	return reflect.TypeOf((*map[string]*IPSet)(nil)).Elem()
   384  }
   385  
   386  func (o IPSetMapOutput) ToIPSetMapOutput() IPSetMapOutput {
   387  	return o
   388  }
   389  
   390  func (o IPSetMapOutput) ToIPSetMapOutputWithContext(ctx context.Context) IPSetMapOutput {
   391  	return o
   392  }
   393  
   394  func (o IPSetMapOutput) MapIndex(k pulumi.StringInput) IPSetOutput {
   395  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *IPSet {
   396  		return vs[0].(map[string]*IPSet)[vs[1].(string)]
   397  	}).(IPSetOutput)
   398  }
   399  
   400  func init() {
   401  	pulumi.RegisterInputType(reflect.TypeOf((*IPSetInput)(nil)).Elem(), &IPSet{})
   402  	pulumi.RegisterInputType(reflect.TypeOf((*IPSetArrayInput)(nil)).Elem(), IPSetArray{})
   403  	pulumi.RegisterInputType(reflect.TypeOf((*IPSetMapInput)(nil)).Elem(), IPSetMap{})
   404  	pulumi.RegisterOutputType(IPSetOutput{})
   405  	pulumi.RegisterOutputType(IPSetArrayOutput{})
   406  	pulumi.RegisterOutputType(IPSetMapOutput{})
   407  }