Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sesv2 data sources for email identity and mail from attributes #32026

Merged
merged 9 commits into from
Jun 22, 2023
7 changes: 4 additions & 3 deletions internal/service/sesv2/email_identity_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ const (
)

func dataSourceEmailIdentityRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).SESV2Client(ctx)

name := d.Get("email_identity").(string)

out, err := FindEmailIdentityByID(ctx, conn, name)
if err != nil {
return create.DiagError(names.SESV2, create.ErrActionReading, DSNameEmailIdentity, name, err)
return append(diags, create.DiagError(names.SESV2, create.ErrActionReading, DSNameEmailIdentity, name, err)...)
}

arn := emailIdentityNameToARN(meta, name)
Expand All @@ -111,7 +112,7 @@ func dataSourceEmailIdentityRead(ctx context.Context, d *schema.ResourceData, me
tfMap["domain_signing_selector"] = d.Get("dkim_signing_attributes.0.domain_signing_selector").(string)

if err := d.Set("dkim_signing_attributes", []interface{}{tfMap}); err != nil {
return create.DiagError(names.SESV2, create.ErrActionSetting, ResNameEmailIdentity, name, err)
return append(diags, create.DiagError(names.SESV2, create.ErrActionSetting, ResNameEmailIdentity, name, err)...)
}
} else {
d.Set("dkim_signing_attributes", nil)
Expand All @@ -120,5 +121,5 @@ func dataSourceEmailIdentityRead(ctx context.Context, d *schema.ResourceData, me
d.Set("identity_type", string(out.IdentityType))
d.Set("verified_for_sending_status", out.VerifiedForSendingStatus)

return nil
return diags
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my edification, why is this commit necessary? Do folks add diagnostics in non-error cases? Is this just setting up for a future where we may add diagnostics all throughout this function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter - future-proofing for cases where we might add non-error diagnostics. The newer Plugin-Framework uses this diagnostics pattern, so we try to make Plugin-SDK based resources look similar.

There are a bunch of legacy Plugin-SDK based resources that don't look this way, but when new stuff comes in its a simple enough change we usually switch over.

}