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

feat(sesv2): Implement Simple Email Service v2 resources #791

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

kelvinwijaya
Copy link
Contributor

@kelvinwijaya kelvinwijaya commented Aug 9, 2021

Description of your changes

Fixes #414

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

  • Tried Create resource operation with examples of custom resource manifests
  • Make sure Readiness Status shown as True and Condition as Available when the resources are provisioned successfully
  • Monitor Readiness Status shown as False and Condition as Unavailable OR Creating if wrong parameters being supplied in the custom resource manifests
  • Tried various Update resource operations depending on the targetted functionality especially when there is more than 1 PUT API operations.
  • Tried Delete operation of the resource and get deleted successfully

Test plan based on examples template:

  1. Test emailidentity CRD operations for email address (verified with email acknowledgement status)
  2. Test emailidentity CRD operations for domain (verified with DKIM and MailFrom status)
  3. Test emailidentity Update operations for ConfigurationSetAttributes
  4. Test emailidentity Update operations for MailFromAttributes
  5. Test configurationset CRD operations which is referenced in the emailidentity
  6. Test configurationset Update operations for DeliveryOptions
  7. Test configurationset Update operations for ReputationOptions
  8. Test configurationset Update operations for SuppressionOptions
  9. Test configurationset Update operations for SendingOptions
  10. Test configurationset Update operations for TrackingOptions
  11. Test emailtemplate CRUD operations with HTML,Subject,Text

@kelvinwijaya
Copy link
Contributor Author

kelvinwijaya commented Aug 9, 2021

Hi @muvaf @negz @hasheddan

I have just submitted a PR, not sure what causing the CI/check-diff step failing, can advise on this?

Is it because i modified some of the zz_.go file, which kind is allowed to be changed and not allowed to (e.g. zz_conversion.go or zz_generated_.go)?

Thanks,
Kelvin

@chlunde
Copy link
Collaborator

chlunde commented Aug 9, 2021

@kelvinwijaya yeah, I think it's either

  • because you modified a generated file
  • or didn't run make generate after rebasing/with the same tools, or after a local change

try make check-diff locally (make generate; git diff)

apis/sesv2/v1alpha1/zz_email_i_dentity.go Outdated Show resolved Hide resolved
apis/sesv2/v1alpha1/generator-config.yaml Outdated Show resolved Hide resolved
@kelvinwijaya
Copy link
Contributor Author

kelvinwijaya commented Aug 10, 2021

@kelvinwijaya yeah, I think it's either

  • because you modified a generated file
  • or didn't run make generate after rebasing/with the same tools, or after a local change

try make check-diff locally (make generate; git diff)

Thanks @chlunde

I have rebased my code and removed handwritten code from the auto-generated one. But i noticed errors during the go building process:
ERRO Running error: buildir: analysis skipped: errors in package: [/Users/kelvinwijaya/go/src/github.com/kelvinwijaya/provider-aws/pkg/controller/sesv2/configurationseteventdestination/zz_conversions.go:48:9: elem declared but not used] 09:06:52 [FAIL]

Problem is if I don't modify this file to make it work as below, it wont compile:
Original:

for _, elem := range resp.EventDestinations {
		found = true
		break
	}

After modification (no compile error):

for _, elem := range resp.EventDestinations {
		if elem.Name != nil {
			found = true
			break
		}
	}

But after making this modification and commit the code. I ran make generate again and issue is this zz_conversion.go file will be overwritten again by the code-generator as there is diff. How do we resolve this before if i push this code? Else, the CI/check-diff will definitely throw error again.

Slack Thread: https://crossplane.slack.com/archives/C01718T2476/p1628649932065800

@muvaf
Copy link
Member

muvaf commented Aug 12, 2021

@kelvinwijaya I wonder why the content of the for loop is empty. From your message in Slack, it seems it has some fields that should be used in the for loop. I think we need to open an issue there and to get the PR going, you can add this specific resource to the ignore list. Once the issue is addressed there, we can get back to adding it.

@kelvinwijaya
Copy link
Contributor Author

Thanks @muvaf for your input, i will open a new case in aws-controller-k8s/code-generator project. I have excluded the problematic resource configurationseteventdestination so that this PR can keep going. This resource is not essential for SES to work , so I think I am good as for now and will definitely add it back when the code-generator fixes has been made

Thanks @chlunde also for pointing out the issue in code-generator, I will follow-up by opening an issue ticket with them

I have make sure All check have passed and would require you and other maintainers for the reviews. Many thanks in advanced.

@kelvinwijaya
Copy link
Contributor Author

I have open a case to aws-controllers-k8s/community on the code-generation issue: aws-controllers-k8s/community#898

@kelvinwijaya kelvinwijaya force-pushed the v1alpha1-sesv2 branch 2 times, most recently from 93f5033 to a8f0049 Compare August 25, 2021 15:17
@kelvinwijaya
Copy link
Contributor Author

Hi @chlunde

I have added Update operations for TrackingOptions. Feel free to review my PR whenever you ready or available

@AaronME
Copy link
Collaborator

AaronME commented Sep 24, 2021

@chlunde Would you mind taking another look and confirming your comments are resolved?

@kelvinwijaya
Copy link
Contributor Author

Hi @chlunde @AaronME

Would like to check if this PR will be pushed to the next provider-aws release

@kelvinwijaya
Copy link
Contributor Author

Adding comment for reminder as this PR is currently blocked by:
#801 has been closed and replaced by #918

@kelvinwijaya
Copy link
Contributor Author

Hi @chlunde @AaronME

It has been a while that this PR is blocked due to #801 #918, Is there a way we can push this implementation first while waiting for that. It was quite troublesome for my organization as we have to maintain downstream repo to support this additional feature

@kelvinwijaya
Copy link
Contributor Author

Hi @chlunde @AaronME

Please ignore my comment earlier.

I notice the code-generator is now referencing to newer version (v0.14.1) with commit: 285d87b66b62fbfb859986ddf74c9f9b6ae743fb

Let me update the changes accordingly and update your guys with the new commit, I believe this should fix the zz_email_i_dentity.go and CustomEmailIDentityObservation and hopefully we can close this issue.

Thanks

@kelvinwijaya kelvinwijaya force-pushed the v1alpha1-sesv2 branch 2 times, most recently from c96f1bd to 26f296d Compare January 17, 2022 05:27
@kelvinwijaya
Copy link
Contributor Author

Hi @chlunde

I have done with my changes using the latest code-generator
Please help me review this PR again.

Many thanks!

@kelvinwijaya
Copy link
Contributor Author

Hi @haarchri

Saw the upcoming release for provider-aws for v0.24.0: #1061

Currently this PR is still pending for review, will there be anyone in community to help out on this? I really hope this SES resource can be integrated to the aws provider release soon.

Copy link
Member

@muvaf muvaf left a comment

Choose a reason for hiding this comment

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

Thanks @kelvinwijaya !

Makefile Outdated Show resolved Hide resolved
DkimSigningAttributes *DkimSigningAttributes `json:"dkimSigningAttributes,omitempty"`
// The email address or domain that you want to verify.
// +kubebuilder:validation:Required
EmailIdentity *string `json:"emailIdentity"`
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be taken from the external name annotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not changing to external name annotation in consideration with email identity contain characters (e.g. my@acme.com) that is not valid k8s metadata name

pkg/controller/sesv2/emailidentity/setup.go Outdated Show resolved Hide resolved
pkg/controller/sesv2/emailidentity/setup.go Outdated Show resolved Hide resolved
pkg/controller/sesv2/emailidentity/setup.go Outdated Show resolved Hide resolved
pkg/controller/sesv2/configurationset/setup.go Outdated Show resolved Hide resolved
}

// UpdateTagsForResource with resourceName
func UpdateTagsForResource(client sesv2iface.SESV2API, spec []*svcapitypes.Tag, resourceArn *string) error {
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this is never used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, keeping the code once able to figure out: // TODO(kelvinwijaya): Updating Tags will be useful if we can determine the resourceArn from the Status return by Observation state object

Copy link
Collaborator

Choose a reason for hiding this comment

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

Whats blocking this TODO from being implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As for ConfigurationSet resource, the creation of Tags is passed via CreateConfigurationSet API only: https://docs.aws.amazon.com/ses/latest/APIReference-V2/API_CreateConfigurationSet.html

As for today, the tagging API only support update via arn format resource name which i cannot retrieve from the GET api: https://docs.aws.amazon.com/ses/latest/APIReference-V2/API_TagResource.html

I am keeping the code for future usage, but i can remove if this cause confusion as not being used for now.


tags := spec
for _, t := range GetExternalTags(mg) {
if _, exists := tagMap[awsclient.StringValue(t.Key)]; !exists {
Copy link
Member

Choose a reason for hiding this comment

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

We should override its value if it exists.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure on this one. If the user specifies a different value in the spec the controller should keep it. We some issues with this in the past.

I would keep it the way it is and only set tag values if the key isn't present already.

}

// AddExternalTags to spec if they don't exist
func AddExternalTags(mg resource.Managed, spec []*svcapitypes.Tag) []*svcapitypes.Tag {
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to have an implementation similar to this one that covers all cases including composition and ordering? https://github.com/crossplane/provider-aws/blob/8be1568/pkg/controller/ecr/repository/controller.go#L246

@AaronME AaronME removed their assignment Jun 7, 2022
@haarchri
Copy link
Member

@kelvinwijaya any chance to check the Open Points that we can finalize this PR ?

@kelvinwijaya
Copy link
Contributor Author

Hi @haarchri

Let me have a look at the open points and try to resolve the review comments

@MisterMX
Copy link
Collaborator

@kelvinwijaya can you fix the issues and rebase to the latest master? Then we can work on getting this merged.

@kelvinwijaya
Copy link
Contributor Author

@MisterMX , absolutely.. let me plan on review issues and merge the changes

@kelvinwijaya
Copy link
Contributor Author

kelvinwijaya commented Jul 12, 2023

@MisterMX , for your review 7ff090b

@kelvinwijaya kelvinwijaya force-pushed the v1alpha1-sesv2 branch 4 times, most recently from 28aabd9 to b9cd5da Compare July 16, 2023 04:44
@kelvinwijaya
Copy link
Contributor Author

@MisterMX, added changes based on some reviews that i missed as conversation is not auto-populated in File changed due to comment given for autogenerated files (zz_files): b9cd5da

pkg/controller/sesv2/configurationset/setup.go Outdated Show resolved Hide resolved
pkg/controller/sesv2/configurationset/setup.go Outdated Show resolved Hide resolved
pkg/controller/sesv2/configurationset/setup.go Outdated Show resolved Hide resolved
pkg/controller/sesv2/configurationset/setup.go Outdated Show resolved Hide resolved
pkg/controller/sesv2/configurationset/setup.go Outdated Show resolved Hide resolved
pkg/controller/sesv2/configurationset/setup.go Outdated Show resolved Hide resolved

tags := spec
for _, t := range GetExternalTags(mg) {
if _, exists := tagMap[awsclient.StringValue(t.Key)]; !exists {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure on this one. If the user specifies a different value in the spec the controller should keep it. We some issues with this in the past.

I would keep it the way it is and only set tag values if the key isn't present already.

}

// UpdateTagsForResource with resourceName
func UpdateTagsForResource(client sesv2iface.SESV2API, spec []*svcapitypes.Tag, resourceArn *string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Whats blocking this TODO from being implemented?

@MisterMX MisterMX changed the title Implement Simple Email Service (SES) v2 resources feat(sesv2): Implement Simple Email Service v2 resources Jul 25, 2023
@kelvinwijaya kelvinwijaya force-pushed the v1alpha1-sesv2 branch 2 times, most recently from 91e2adb to 7e8c19e Compare July 25, 2023 15:31
Copy link
Collaborator

@MisterMX MisterMX left a comment

Choose a reason for hiding this comment

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

Looks almost good to me. Only some minor issues remaining. @guilhermef after solving these can you squash your changes into a single commit?

pkg/controller/sesv2/configurationset/setup.go Outdated Show resolved Hide resolved
pkg/controller/sesv2/configurationset/setup.go Outdated Show resolved Hide resolved
pkg/controller/sesv2/configurationset/setup.go Outdated Show resolved Hide resolved
CustomRedirectDomain: cr.Spec.ForProvider.TrackingOptions.CustomRedirectDomain,
}
if _, err := e.client.PutConfigurationSetTrackingOptionsWithContext(ctx, trackingOptionInput); err != nil {
return managed.ExternalUpdate{}, errors.Wrap(err, "update failed")
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be a different error message for each Wrap to help identify where the error came from. "update failed" is too generic here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

SendingEnabled: cr.Spec.ForProvider.SendingOptions.SendingEnabled,
}
if _, err := e.client.PutConfigurationSetSendingOptionsWithContext(ctx, sendingOptionInput); err != nil {
return managed.ExternalUpdate{}, errors.Wrap(err, "update failed")
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be a different error message for each Wrap to help identify where the error came from. "update failed" is too generic here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

EmailIdentity: cr.Spec.ForProvider.EmailIdentity,
}
if _, err := e.client.PutEmailIdentityConfigurationSetAttributesWithContext(ctx, configurationSetAttributesInput); err != nil {
return managed.ExternalUpdate{}, errors.Wrap(err, "update failed")
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be a different error message for each Wrap to help identify where the error came from. "update failed" is too generic here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

}

if _, err := e.client.PutEmailIdentityMailFromAttributesWithContext(ctx, mailFromAttributesInput); err != nil {
return managed.ExternalUpdate{}, errors.Wrap(err, "update failed")
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be a different error message for each Wrap to help identify where the error came from. "update failed" is too generic here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

SigningAttributesOrigin: awsclient.String(dkimSigningAttributeExternal),
}
if _, err := e.client.PutEmailIdentityDkimSigningAttributesWithContext(ctx, dkimSigningAttributesInput); err != nil {
return managed.ExternalUpdate{}, errors.Wrap(err, "update failed")
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be a different error message for each Wrap to help identify where the error came from. "update failed" is too generic here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

},
}
if _, err := e.client.PutEmailIdentityDkimSigningAttributesWithContext(ctx, dkimSigningAttributesInput); err != nil {
return managed.ExternalUpdate{}, errors.Wrap(err, "update failed")
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be a different error message for each Wrap to help identify where the error came from. "update failed" is too generic here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

Signed-off-by: kelvinwijaya <kelvin_wijaya@tech.gov.sg>
@kelvinwijaya
Copy link
Contributor Author

@MisterMX , thanks for your kind review and i have squashed the commit messages

Copy link
Collaborator

@MisterMX MisterMX left a comment

Choose a reason for hiding this comment

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

@kelvinwijaya thank you very much for your contribution! LGTM.

@MisterMX MisterMX merged commit 0d1846d into crossplane-contrib:master Jul 26, 2023
8 checks passed
@MisterMX MisterMX mentioned this pull request Jul 28, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Simple Email Service (SES) resources
6 participants