github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/sesv2/emailIdentityPolicy.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 sesv2
     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  // Resource for managing an AWS SESv2 (Simple Email V2) Email Identity Policy.
    16  //
    17  // ## Example Usage
    18  //
    19  // ### Basic 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/sesv2"
    30  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			example, err := sesv2.NewEmailIdentity(ctx, "example", &sesv2.EmailIdentityArgs{
    37  //				EmailIdentity: pulumi.String("testing@example.com"),
    38  //			})
    39  //			if err != nil {
    40  //				return err
    41  //			}
    42  //			_, err = sesv2.NewEmailIdentityPolicy(ctx, "example", &sesv2.EmailIdentityPolicyArgs{
    43  //				EmailIdentity: example.EmailIdentity,
    44  //				PolicyName:    pulumi.String("example"),
    45  //				Policy: example.Arn.ApplyT(func(arn string) (string, error) {
    46  //					return fmt.Sprintf(`{
    47  //	  "Id":"ExampleAuthorizationPolicy",
    48  //	  "Version":"2012-10-17",
    49  //	  "Statement":[
    50  //	    {
    51  //	      "Sid":"AuthorizeIAMUser",
    52  //	      "Effect":"Allow",
    53  //	      "Resource":"%v",
    54  //	      "Principal":{
    55  //	        "AWS":[
    56  //	          "arn:aws:iam::123456789012:user/John",
    57  //	          "arn:aws:iam::123456789012:user/Jane"
    58  //	        ]
    59  //	      },
    60  //	      "Action":[
    61  //	        "ses:DeleteEmailIdentity",
    62  //	        "ses:PutEmailIdentityDkimSigningAttributes"
    63  //	      ]
    64  //	    }
    65  //	  ]
    66  //	}
    67  //
    68  // `, arn), nil
    69  //
    70  //				}).(pulumi.StringOutput),
    71  //			})
    72  //			if err != nil {
    73  //				return err
    74  //			}
    75  //			return nil
    76  //		})
    77  //	}
    78  //
    79  // ```
    80  // <!--End PulumiCodeChooser -->
    81  //
    82  // ## Import
    83  //
    84  // Using `pulumi import`, import SESv2 (Simple Email V2) Email Identity Policy using the `example_id_arg`. For example:
    85  //
    86  // ```sh
    87  // $ pulumi import aws:sesv2/emailIdentityPolicy:EmailIdentityPolicy example example_email_identity|example_policy_name
    88  // ```
    89  type EmailIdentityPolicy struct {
    90  	pulumi.CustomResourceState
    91  
    92  	// The email identity.
    93  	EmailIdentity pulumi.StringOutput `pulumi:"emailIdentity"`
    94  	// The text of the policy in JSON format.
    95  	Policy pulumi.StringOutput `pulumi:"policy"`
    96  	// The name of the policy.
    97  	PolicyName pulumi.StringOutput `pulumi:"policyName"`
    98  }
    99  
   100  // NewEmailIdentityPolicy registers a new resource with the given unique name, arguments, and options.
   101  func NewEmailIdentityPolicy(ctx *pulumi.Context,
   102  	name string, args *EmailIdentityPolicyArgs, opts ...pulumi.ResourceOption) (*EmailIdentityPolicy, error) {
   103  	if args == nil {
   104  		return nil, errors.New("missing one or more required arguments")
   105  	}
   106  
   107  	if args.EmailIdentity == nil {
   108  		return nil, errors.New("invalid value for required argument 'EmailIdentity'")
   109  	}
   110  	if args.Policy == nil {
   111  		return nil, errors.New("invalid value for required argument 'Policy'")
   112  	}
   113  	if args.PolicyName == nil {
   114  		return nil, errors.New("invalid value for required argument 'PolicyName'")
   115  	}
   116  	opts = internal.PkgResourceDefaultOpts(opts)
   117  	var resource EmailIdentityPolicy
   118  	err := ctx.RegisterResource("aws:sesv2/emailIdentityPolicy:EmailIdentityPolicy", name, args, &resource, opts...)
   119  	if err != nil {
   120  		return nil, err
   121  	}
   122  	return &resource, nil
   123  }
   124  
   125  // GetEmailIdentityPolicy gets an existing EmailIdentityPolicy resource's state with the given name, ID, and optional
   126  // state properties that are used to uniquely qualify the lookup (nil if not required).
   127  func GetEmailIdentityPolicy(ctx *pulumi.Context,
   128  	name string, id pulumi.IDInput, state *EmailIdentityPolicyState, opts ...pulumi.ResourceOption) (*EmailIdentityPolicy, error) {
   129  	var resource EmailIdentityPolicy
   130  	err := ctx.ReadResource("aws:sesv2/emailIdentityPolicy:EmailIdentityPolicy", name, id, state, &resource, opts...)
   131  	if err != nil {
   132  		return nil, err
   133  	}
   134  	return &resource, nil
   135  }
   136  
   137  // Input properties used for looking up and filtering EmailIdentityPolicy resources.
   138  type emailIdentityPolicyState struct {
   139  	// The email identity.
   140  	EmailIdentity *string `pulumi:"emailIdentity"`
   141  	// The text of the policy in JSON format.
   142  	Policy *string `pulumi:"policy"`
   143  	// The name of the policy.
   144  	PolicyName *string `pulumi:"policyName"`
   145  }
   146  
   147  type EmailIdentityPolicyState struct {
   148  	// The email identity.
   149  	EmailIdentity pulumi.StringPtrInput
   150  	// The text of the policy in JSON format.
   151  	Policy pulumi.StringPtrInput
   152  	// The name of the policy.
   153  	PolicyName pulumi.StringPtrInput
   154  }
   155  
   156  func (EmailIdentityPolicyState) ElementType() reflect.Type {
   157  	return reflect.TypeOf((*emailIdentityPolicyState)(nil)).Elem()
   158  }
   159  
   160  type emailIdentityPolicyArgs struct {
   161  	// The email identity.
   162  	EmailIdentity string `pulumi:"emailIdentity"`
   163  	// The text of the policy in JSON format.
   164  	Policy string `pulumi:"policy"`
   165  	// The name of the policy.
   166  	PolicyName string `pulumi:"policyName"`
   167  }
   168  
   169  // The set of arguments for constructing a EmailIdentityPolicy resource.
   170  type EmailIdentityPolicyArgs struct {
   171  	// The email identity.
   172  	EmailIdentity pulumi.StringInput
   173  	// The text of the policy in JSON format.
   174  	Policy pulumi.StringInput
   175  	// The name of the policy.
   176  	PolicyName pulumi.StringInput
   177  }
   178  
   179  func (EmailIdentityPolicyArgs) ElementType() reflect.Type {
   180  	return reflect.TypeOf((*emailIdentityPolicyArgs)(nil)).Elem()
   181  }
   182  
   183  type EmailIdentityPolicyInput interface {
   184  	pulumi.Input
   185  
   186  	ToEmailIdentityPolicyOutput() EmailIdentityPolicyOutput
   187  	ToEmailIdentityPolicyOutputWithContext(ctx context.Context) EmailIdentityPolicyOutput
   188  }
   189  
   190  func (*EmailIdentityPolicy) ElementType() reflect.Type {
   191  	return reflect.TypeOf((**EmailIdentityPolicy)(nil)).Elem()
   192  }
   193  
   194  func (i *EmailIdentityPolicy) ToEmailIdentityPolicyOutput() EmailIdentityPolicyOutput {
   195  	return i.ToEmailIdentityPolicyOutputWithContext(context.Background())
   196  }
   197  
   198  func (i *EmailIdentityPolicy) ToEmailIdentityPolicyOutputWithContext(ctx context.Context) EmailIdentityPolicyOutput {
   199  	return pulumi.ToOutputWithContext(ctx, i).(EmailIdentityPolicyOutput)
   200  }
   201  
   202  // EmailIdentityPolicyArrayInput is an input type that accepts EmailIdentityPolicyArray and EmailIdentityPolicyArrayOutput values.
   203  // You can construct a concrete instance of `EmailIdentityPolicyArrayInput` via:
   204  //
   205  //	EmailIdentityPolicyArray{ EmailIdentityPolicyArgs{...} }
   206  type EmailIdentityPolicyArrayInput interface {
   207  	pulumi.Input
   208  
   209  	ToEmailIdentityPolicyArrayOutput() EmailIdentityPolicyArrayOutput
   210  	ToEmailIdentityPolicyArrayOutputWithContext(context.Context) EmailIdentityPolicyArrayOutput
   211  }
   212  
   213  type EmailIdentityPolicyArray []EmailIdentityPolicyInput
   214  
   215  func (EmailIdentityPolicyArray) ElementType() reflect.Type {
   216  	return reflect.TypeOf((*[]*EmailIdentityPolicy)(nil)).Elem()
   217  }
   218  
   219  func (i EmailIdentityPolicyArray) ToEmailIdentityPolicyArrayOutput() EmailIdentityPolicyArrayOutput {
   220  	return i.ToEmailIdentityPolicyArrayOutputWithContext(context.Background())
   221  }
   222  
   223  func (i EmailIdentityPolicyArray) ToEmailIdentityPolicyArrayOutputWithContext(ctx context.Context) EmailIdentityPolicyArrayOutput {
   224  	return pulumi.ToOutputWithContext(ctx, i).(EmailIdentityPolicyArrayOutput)
   225  }
   226  
   227  // EmailIdentityPolicyMapInput is an input type that accepts EmailIdentityPolicyMap and EmailIdentityPolicyMapOutput values.
   228  // You can construct a concrete instance of `EmailIdentityPolicyMapInput` via:
   229  //
   230  //	EmailIdentityPolicyMap{ "key": EmailIdentityPolicyArgs{...} }
   231  type EmailIdentityPolicyMapInput interface {
   232  	pulumi.Input
   233  
   234  	ToEmailIdentityPolicyMapOutput() EmailIdentityPolicyMapOutput
   235  	ToEmailIdentityPolicyMapOutputWithContext(context.Context) EmailIdentityPolicyMapOutput
   236  }
   237  
   238  type EmailIdentityPolicyMap map[string]EmailIdentityPolicyInput
   239  
   240  func (EmailIdentityPolicyMap) ElementType() reflect.Type {
   241  	return reflect.TypeOf((*map[string]*EmailIdentityPolicy)(nil)).Elem()
   242  }
   243  
   244  func (i EmailIdentityPolicyMap) ToEmailIdentityPolicyMapOutput() EmailIdentityPolicyMapOutput {
   245  	return i.ToEmailIdentityPolicyMapOutputWithContext(context.Background())
   246  }
   247  
   248  func (i EmailIdentityPolicyMap) ToEmailIdentityPolicyMapOutputWithContext(ctx context.Context) EmailIdentityPolicyMapOutput {
   249  	return pulumi.ToOutputWithContext(ctx, i).(EmailIdentityPolicyMapOutput)
   250  }
   251  
   252  type EmailIdentityPolicyOutput struct{ *pulumi.OutputState }
   253  
   254  func (EmailIdentityPolicyOutput) ElementType() reflect.Type {
   255  	return reflect.TypeOf((**EmailIdentityPolicy)(nil)).Elem()
   256  }
   257  
   258  func (o EmailIdentityPolicyOutput) ToEmailIdentityPolicyOutput() EmailIdentityPolicyOutput {
   259  	return o
   260  }
   261  
   262  func (o EmailIdentityPolicyOutput) ToEmailIdentityPolicyOutputWithContext(ctx context.Context) EmailIdentityPolicyOutput {
   263  	return o
   264  }
   265  
   266  // The email identity.
   267  func (o EmailIdentityPolicyOutput) EmailIdentity() pulumi.StringOutput {
   268  	return o.ApplyT(func(v *EmailIdentityPolicy) pulumi.StringOutput { return v.EmailIdentity }).(pulumi.StringOutput)
   269  }
   270  
   271  // The text of the policy in JSON format.
   272  func (o EmailIdentityPolicyOutput) Policy() pulumi.StringOutput {
   273  	return o.ApplyT(func(v *EmailIdentityPolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)
   274  }
   275  
   276  // The name of the policy.
   277  func (o EmailIdentityPolicyOutput) PolicyName() pulumi.StringOutput {
   278  	return o.ApplyT(func(v *EmailIdentityPolicy) pulumi.StringOutput { return v.PolicyName }).(pulumi.StringOutput)
   279  }
   280  
   281  type EmailIdentityPolicyArrayOutput struct{ *pulumi.OutputState }
   282  
   283  func (EmailIdentityPolicyArrayOutput) ElementType() reflect.Type {
   284  	return reflect.TypeOf((*[]*EmailIdentityPolicy)(nil)).Elem()
   285  }
   286  
   287  func (o EmailIdentityPolicyArrayOutput) ToEmailIdentityPolicyArrayOutput() EmailIdentityPolicyArrayOutput {
   288  	return o
   289  }
   290  
   291  func (o EmailIdentityPolicyArrayOutput) ToEmailIdentityPolicyArrayOutputWithContext(ctx context.Context) EmailIdentityPolicyArrayOutput {
   292  	return o
   293  }
   294  
   295  func (o EmailIdentityPolicyArrayOutput) Index(i pulumi.IntInput) EmailIdentityPolicyOutput {
   296  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *EmailIdentityPolicy {
   297  		return vs[0].([]*EmailIdentityPolicy)[vs[1].(int)]
   298  	}).(EmailIdentityPolicyOutput)
   299  }
   300  
   301  type EmailIdentityPolicyMapOutput struct{ *pulumi.OutputState }
   302  
   303  func (EmailIdentityPolicyMapOutput) ElementType() reflect.Type {
   304  	return reflect.TypeOf((*map[string]*EmailIdentityPolicy)(nil)).Elem()
   305  }
   306  
   307  func (o EmailIdentityPolicyMapOutput) ToEmailIdentityPolicyMapOutput() EmailIdentityPolicyMapOutput {
   308  	return o
   309  }
   310  
   311  func (o EmailIdentityPolicyMapOutput) ToEmailIdentityPolicyMapOutputWithContext(ctx context.Context) EmailIdentityPolicyMapOutput {
   312  	return o
   313  }
   314  
   315  func (o EmailIdentityPolicyMapOutput) MapIndex(k pulumi.StringInput) EmailIdentityPolicyOutput {
   316  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *EmailIdentityPolicy {
   317  		return vs[0].(map[string]*EmailIdentityPolicy)[vs[1].(string)]
   318  	}).(EmailIdentityPolicyOutput)
   319  }
   320  
   321  func init() {
   322  	pulumi.RegisterInputType(reflect.TypeOf((*EmailIdentityPolicyInput)(nil)).Elem(), &EmailIdentityPolicy{})
   323  	pulumi.RegisterInputType(reflect.TypeOf((*EmailIdentityPolicyArrayInput)(nil)).Elem(), EmailIdentityPolicyArray{})
   324  	pulumi.RegisterInputType(reflect.TypeOf((*EmailIdentityPolicyMapInput)(nil)).Elem(), EmailIdentityPolicyMap{})
   325  	pulumi.RegisterOutputType(EmailIdentityPolicyOutput{})
   326  	pulumi.RegisterOutputType(EmailIdentityPolicyArrayOutput{})
   327  	pulumi.RegisterOutputType(EmailIdentityPolicyMapOutput{})
   328  }