github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ses/mailFrom.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 ses
     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 SES domain MAIL FROM resource.
    16  //
    17  // > **NOTE:** For the MAIL FROM domain to be fully usable, this resource should be paired with the ses.DomainIdentity resource. To validate the MAIL FROM domain, a DNS MX record is required. To pass SPF checks, a DNS TXT record may also be required. See the [Amazon SES MAIL FROM documentation](https://docs.aws.amazon.com/ses/latest/dg/mail-from.html) for more information.
    18  //
    19  // ## Example Usage
    20  //
    21  // ### Domain Identity MAIL FROM
    22  //
    23  // <!--Start PulumiCodeChooser -->
    24  // ```go
    25  // package main
    26  //
    27  // import (
    28  //
    29  //	"fmt"
    30  //
    31  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/route53"
    32  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ses"
    33  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    34  //
    35  // )
    36  //
    37  //	func main() {
    38  //		pulumi.Run(func(ctx *pulumi.Context) error {
    39  //			// Example SES Domain Identity
    40  //			exampleDomainIdentity, err := ses.NewDomainIdentity(ctx, "example", &ses.DomainIdentityArgs{
    41  //				Domain: pulumi.String("example.com"),
    42  //			})
    43  //			if err != nil {
    44  //				return err
    45  //			}
    46  //			example, err := ses.NewMailFrom(ctx, "example", &ses.MailFromArgs{
    47  //				Domain: exampleDomainIdentity.Domain,
    48  //				MailFromDomain: exampleDomainIdentity.Domain.ApplyT(func(domain string) (string, error) {
    49  //					return fmt.Sprintf("bounce.%v", domain), nil
    50  //				}).(pulumi.StringOutput),
    51  //			})
    52  //			if err != nil {
    53  //				return err
    54  //			}
    55  //			// Example Route53 MX record
    56  //			_, err = route53.NewRecord(ctx, "example_ses_domain_mail_from_mx", &route53.RecordArgs{
    57  //				ZoneId: pulumi.Any(exampleAwsRoute53Zone.Id),
    58  //				Name:   example.MailFromDomain,
    59  //				Type:   pulumi.String(route53.RecordTypeMX),
    60  //				Ttl:    pulumi.Int(600),
    61  //				Records: pulumi.StringArray{
    62  //					pulumi.String("10 feedback-smtp.us-east-1.amazonses.com"),
    63  //				},
    64  //			})
    65  //			if err != nil {
    66  //				return err
    67  //			}
    68  //			// Example Route53 TXT record for SPF
    69  //			_, err = route53.NewRecord(ctx, "example_ses_domain_mail_from_txt", &route53.RecordArgs{
    70  //				ZoneId: pulumi.Any(exampleAwsRoute53Zone.Id),
    71  //				Name:   example.MailFromDomain,
    72  //				Type:   pulumi.String(route53.RecordTypeTXT),
    73  //				Ttl:    pulumi.Int(600),
    74  //				Records: pulumi.StringArray{
    75  //					pulumi.String("v=spf1 include:amazonses.com -all"),
    76  //				},
    77  //			})
    78  //			if err != nil {
    79  //				return err
    80  //			}
    81  //			return nil
    82  //		})
    83  //	}
    84  //
    85  // ```
    86  // <!--End PulumiCodeChooser -->
    87  //
    88  // ### Email Identity MAIL FROM
    89  //
    90  // <!--Start PulumiCodeChooser -->
    91  // ```go
    92  // package main
    93  //
    94  // import (
    95  //
    96  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ses"
    97  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    98  //
    99  // )
   100  //
   101  //	func main() {
   102  //		pulumi.Run(func(ctx *pulumi.Context) error {
   103  //			// Example SES Email Identity
   104  //			example, err := ses.NewEmailIdentity(ctx, "example", &ses.EmailIdentityArgs{
   105  //				Email: pulumi.String("user@example.com"),
   106  //			})
   107  //			if err != nil {
   108  //				return err
   109  //			}
   110  //			_, err = ses.NewMailFrom(ctx, "example", &ses.MailFromArgs{
   111  //				Domain:         example.Email,
   112  //				MailFromDomain: pulumi.String("mail.example.com"),
   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 MAIL FROM domain using the `domain` attribute. For example:
   127  //
   128  // ```sh
   129  // $ pulumi import aws:ses/mailFrom:MailFrom example example.com
   130  // ```
   131  type MailFrom struct {
   132  	pulumi.CustomResourceState
   133  
   134  	// The action that you want Amazon SES to take if it cannot successfully read the required MX record when you send an email. Defaults to `UseDefaultValue`. See the [SES API documentation](https://docs.aws.amazon.com/ses/latest/APIReference/API_SetIdentityMailFromDomain.html) for more information.
   135  	BehaviorOnMxFailure pulumi.StringPtrOutput `pulumi:"behaviorOnMxFailure"`
   136  	// Verified domain name or email identity to generate DKIM tokens for.
   137  	Domain pulumi.StringOutput `pulumi:"domain"`
   138  	// Subdomain (of above domain) which is to be used as MAIL FROM address (Required for DMARC validation)
   139  	//
   140  	// The following arguments are optional:
   141  	MailFromDomain pulumi.StringOutput `pulumi:"mailFromDomain"`
   142  }
   143  
   144  // NewMailFrom registers a new resource with the given unique name, arguments, and options.
   145  func NewMailFrom(ctx *pulumi.Context,
   146  	name string, args *MailFromArgs, opts ...pulumi.ResourceOption) (*MailFrom, error) {
   147  	if args == nil {
   148  		return nil, errors.New("missing one or more required arguments")
   149  	}
   150  
   151  	if args.Domain == nil {
   152  		return nil, errors.New("invalid value for required argument 'Domain'")
   153  	}
   154  	if args.MailFromDomain == nil {
   155  		return nil, errors.New("invalid value for required argument 'MailFromDomain'")
   156  	}
   157  	opts = internal.PkgResourceDefaultOpts(opts)
   158  	var resource MailFrom
   159  	err := ctx.RegisterResource("aws:ses/mailFrom:MailFrom", name, args, &resource, opts...)
   160  	if err != nil {
   161  		return nil, err
   162  	}
   163  	return &resource, nil
   164  }
   165  
   166  // GetMailFrom gets an existing MailFrom resource's state with the given name, ID, and optional
   167  // state properties that are used to uniquely qualify the lookup (nil if not required).
   168  func GetMailFrom(ctx *pulumi.Context,
   169  	name string, id pulumi.IDInput, state *MailFromState, opts ...pulumi.ResourceOption) (*MailFrom, error) {
   170  	var resource MailFrom
   171  	err := ctx.ReadResource("aws:ses/mailFrom:MailFrom", name, id, state, &resource, opts...)
   172  	if err != nil {
   173  		return nil, err
   174  	}
   175  	return &resource, nil
   176  }
   177  
   178  // Input properties used for looking up and filtering MailFrom resources.
   179  type mailFromState struct {
   180  	// The action that you want Amazon SES to take if it cannot successfully read the required MX record when you send an email. Defaults to `UseDefaultValue`. See the [SES API documentation](https://docs.aws.amazon.com/ses/latest/APIReference/API_SetIdentityMailFromDomain.html) for more information.
   181  	BehaviorOnMxFailure *string `pulumi:"behaviorOnMxFailure"`
   182  	// Verified domain name or email identity to generate DKIM tokens for.
   183  	Domain *string `pulumi:"domain"`
   184  	// Subdomain (of above domain) which is to be used as MAIL FROM address (Required for DMARC validation)
   185  	//
   186  	// The following arguments are optional:
   187  	MailFromDomain *string `pulumi:"mailFromDomain"`
   188  }
   189  
   190  type MailFromState struct {
   191  	// The action that you want Amazon SES to take if it cannot successfully read the required MX record when you send an email. Defaults to `UseDefaultValue`. See the [SES API documentation](https://docs.aws.amazon.com/ses/latest/APIReference/API_SetIdentityMailFromDomain.html) for more information.
   192  	BehaviorOnMxFailure pulumi.StringPtrInput
   193  	// Verified domain name or email identity to generate DKIM tokens for.
   194  	Domain pulumi.StringPtrInput
   195  	// Subdomain (of above domain) which is to be used as MAIL FROM address (Required for DMARC validation)
   196  	//
   197  	// The following arguments are optional:
   198  	MailFromDomain pulumi.StringPtrInput
   199  }
   200  
   201  func (MailFromState) ElementType() reflect.Type {
   202  	return reflect.TypeOf((*mailFromState)(nil)).Elem()
   203  }
   204  
   205  type mailFromArgs struct {
   206  	// The action that you want Amazon SES to take if it cannot successfully read the required MX record when you send an email. Defaults to `UseDefaultValue`. See the [SES API documentation](https://docs.aws.amazon.com/ses/latest/APIReference/API_SetIdentityMailFromDomain.html) for more information.
   207  	BehaviorOnMxFailure *string `pulumi:"behaviorOnMxFailure"`
   208  	// Verified domain name or email identity to generate DKIM tokens for.
   209  	Domain string `pulumi:"domain"`
   210  	// Subdomain (of above domain) which is to be used as MAIL FROM address (Required for DMARC validation)
   211  	//
   212  	// The following arguments are optional:
   213  	MailFromDomain string `pulumi:"mailFromDomain"`
   214  }
   215  
   216  // The set of arguments for constructing a MailFrom resource.
   217  type MailFromArgs struct {
   218  	// The action that you want Amazon SES to take if it cannot successfully read the required MX record when you send an email. Defaults to `UseDefaultValue`. See the [SES API documentation](https://docs.aws.amazon.com/ses/latest/APIReference/API_SetIdentityMailFromDomain.html) for more information.
   219  	BehaviorOnMxFailure pulumi.StringPtrInput
   220  	// Verified domain name or email identity to generate DKIM tokens for.
   221  	Domain pulumi.StringInput
   222  	// Subdomain (of above domain) which is to be used as MAIL FROM address (Required for DMARC validation)
   223  	//
   224  	// The following arguments are optional:
   225  	MailFromDomain pulumi.StringInput
   226  }
   227  
   228  func (MailFromArgs) ElementType() reflect.Type {
   229  	return reflect.TypeOf((*mailFromArgs)(nil)).Elem()
   230  }
   231  
   232  type MailFromInput interface {
   233  	pulumi.Input
   234  
   235  	ToMailFromOutput() MailFromOutput
   236  	ToMailFromOutputWithContext(ctx context.Context) MailFromOutput
   237  }
   238  
   239  func (*MailFrom) ElementType() reflect.Type {
   240  	return reflect.TypeOf((**MailFrom)(nil)).Elem()
   241  }
   242  
   243  func (i *MailFrom) ToMailFromOutput() MailFromOutput {
   244  	return i.ToMailFromOutputWithContext(context.Background())
   245  }
   246  
   247  func (i *MailFrom) ToMailFromOutputWithContext(ctx context.Context) MailFromOutput {
   248  	return pulumi.ToOutputWithContext(ctx, i).(MailFromOutput)
   249  }
   250  
   251  // MailFromArrayInput is an input type that accepts MailFromArray and MailFromArrayOutput values.
   252  // You can construct a concrete instance of `MailFromArrayInput` via:
   253  //
   254  //	MailFromArray{ MailFromArgs{...} }
   255  type MailFromArrayInput interface {
   256  	pulumi.Input
   257  
   258  	ToMailFromArrayOutput() MailFromArrayOutput
   259  	ToMailFromArrayOutputWithContext(context.Context) MailFromArrayOutput
   260  }
   261  
   262  type MailFromArray []MailFromInput
   263  
   264  func (MailFromArray) ElementType() reflect.Type {
   265  	return reflect.TypeOf((*[]*MailFrom)(nil)).Elem()
   266  }
   267  
   268  func (i MailFromArray) ToMailFromArrayOutput() MailFromArrayOutput {
   269  	return i.ToMailFromArrayOutputWithContext(context.Background())
   270  }
   271  
   272  func (i MailFromArray) ToMailFromArrayOutputWithContext(ctx context.Context) MailFromArrayOutput {
   273  	return pulumi.ToOutputWithContext(ctx, i).(MailFromArrayOutput)
   274  }
   275  
   276  // MailFromMapInput is an input type that accepts MailFromMap and MailFromMapOutput values.
   277  // You can construct a concrete instance of `MailFromMapInput` via:
   278  //
   279  //	MailFromMap{ "key": MailFromArgs{...} }
   280  type MailFromMapInput interface {
   281  	pulumi.Input
   282  
   283  	ToMailFromMapOutput() MailFromMapOutput
   284  	ToMailFromMapOutputWithContext(context.Context) MailFromMapOutput
   285  }
   286  
   287  type MailFromMap map[string]MailFromInput
   288  
   289  func (MailFromMap) ElementType() reflect.Type {
   290  	return reflect.TypeOf((*map[string]*MailFrom)(nil)).Elem()
   291  }
   292  
   293  func (i MailFromMap) ToMailFromMapOutput() MailFromMapOutput {
   294  	return i.ToMailFromMapOutputWithContext(context.Background())
   295  }
   296  
   297  func (i MailFromMap) ToMailFromMapOutputWithContext(ctx context.Context) MailFromMapOutput {
   298  	return pulumi.ToOutputWithContext(ctx, i).(MailFromMapOutput)
   299  }
   300  
   301  type MailFromOutput struct{ *pulumi.OutputState }
   302  
   303  func (MailFromOutput) ElementType() reflect.Type {
   304  	return reflect.TypeOf((**MailFrom)(nil)).Elem()
   305  }
   306  
   307  func (o MailFromOutput) ToMailFromOutput() MailFromOutput {
   308  	return o
   309  }
   310  
   311  func (o MailFromOutput) ToMailFromOutputWithContext(ctx context.Context) MailFromOutput {
   312  	return o
   313  }
   314  
   315  // The action that you want Amazon SES to take if it cannot successfully read the required MX record when you send an email. Defaults to `UseDefaultValue`. See the [SES API documentation](https://docs.aws.amazon.com/ses/latest/APIReference/API_SetIdentityMailFromDomain.html) for more information.
   316  func (o MailFromOutput) BehaviorOnMxFailure() pulumi.StringPtrOutput {
   317  	return o.ApplyT(func(v *MailFrom) pulumi.StringPtrOutput { return v.BehaviorOnMxFailure }).(pulumi.StringPtrOutput)
   318  }
   319  
   320  // Verified domain name or email identity to generate DKIM tokens for.
   321  func (o MailFromOutput) Domain() pulumi.StringOutput {
   322  	return o.ApplyT(func(v *MailFrom) pulumi.StringOutput { return v.Domain }).(pulumi.StringOutput)
   323  }
   324  
   325  // Subdomain (of above domain) which is to be used as MAIL FROM address (Required for DMARC validation)
   326  //
   327  // The following arguments are optional:
   328  func (o MailFromOutput) MailFromDomain() pulumi.StringOutput {
   329  	return o.ApplyT(func(v *MailFrom) pulumi.StringOutput { return v.MailFromDomain }).(pulumi.StringOutput)
   330  }
   331  
   332  type MailFromArrayOutput struct{ *pulumi.OutputState }
   333  
   334  func (MailFromArrayOutput) ElementType() reflect.Type {
   335  	return reflect.TypeOf((*[]*MailFrom)(nil)).Elem()
   336  }
   337  
   338  func (o MailFromArrayOutput) ToMailFromArrayOutput() MailFromArrayOutput {
   339  	return o
   340  }
   341  
   342  func (o MailFromArrayOutput) ToMailFromArrayOutputWithContext(ctx context.Context) MailFromArrayOutput {
   343  	return o
   344  }
   345  
   346  func (o MailFromArrayOutput) Index(i pulumi.IntInput) MailFromOutput {
   347  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *MailFrom {
   348  		return vs[0].([]*MailFrom)[vs[1].(int)]
   349  	}).(MailFromOutput)
   350  }
   351  
   352  type MailFromMapOutput struct{ *pulumi.OutputState }
   353  
   354  func (MailFromMapOutput) ElementType() reflect.Type {
   355  	return reflect.TypeOf((*map[string]*MailFrom)(nil)).Elem()
   356  }
   357  
   358  func (o MailFromMapOutput) ToMailFromMapOutput() MailFromMapOutput {
   359  	return o
   360  }
   361  
   362  func (o MailFromMapOutput) ToMailFromMapOutputWithContext(ctx context.Context) MailFromMapOutput {
   363  	return o
   364  }
   365  
   366  func (o MailFromMapOutput) MapIndex(k pulumi.StringInput) MailFromOutput {
   367  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *MailFrom {
   368  		return vs[0].(map[string]*MailFrom)[vs[1].(string)]
   369  	}).(MailFromOutput)
   370  }
   371  
   372  func init() {
   373  	pulumi.RegisterInputType(reflect.TypeOf((*MailFromInput)(nil)).Elem(), &MailFrom{})
   374  	pulumi.RegisterInputType(reflect.TypeOf((*MailFromArrayInput)(nil)).Elem(), MailFromArray{})
   375  	pulumi.RegisterInputType(reflect.TypeOf((*MailFromMapInput)(nil)).Elem(), MailFromMap{})
   376  	pulumi.RegisterOutputType(MailFromOutput{})
   377  	pulumi.RegisterOutputType(MailFromArrayOutput{})
   378  	pulumi.RegisterOutputType(MailFromMapOutput{})
   379  }