aws-ia / cloudformation-fastly-resource-providers

Fastly CFN Registry resource
Apache License 2.0
2 stars 8 forks source link

How do we update services with new versions? #53

Open AndrewBarba opened 1 year ago

AndrewBarba commented 1 year ago

I'm currently trying to use this in SST which is a wrapper around CDK. I'm able to create the initial service, backend and domain on first deploy but then a bunch of issues crop up:

  1. On initial deploy there is no way to activate the version
  2. On subsequent updates, everything fails because nothing creates a new version and keeps trying to edit the attrLatestVersionId

Is it even possible to use this in its current state? My guess is we need to add a Fastly::Services::Version construct, or any update to an underlying service Fastly::Services::*** needs to know to create a new version first and set it as the latest version. Additionally, we need some way to then activate the latest version once all changes are reconciled and added to the new version

LucasQChen commented 1 year ago

@AndrewBarba let me discuss with some folks about this and what the approach should be. We'll also evaluate adding the new resource.

AndrewBarba commented 1 year ago

Excellent @CloudChoom thanks a lot. And while I have you here, some other key ones I need:

LucasQChen commented 1 year ago

Thanks @AndrewBarba We'll have a look at those as well. Working with the team to get an estimate on each of those. Out of curiosity, are there other 3rd party providers you're looking to use other than Fastly?

AndrewBarba commented 1 year ago

My favorite backend stack:

LucasQChen commented 1 year ago

FYI in case you haven't already seen, we do have CFN resources available for Cloudflare and MongoDB Atlas as well.

https://github.com/aws-ia/cloudformation-cloudflare-resource-providers https://www.mongodb.com/developer/code-examples/bash/get-started-atlas-aws-cloudformation/

LucasQChen commented 1 year ago

Quick update on the Fastly resource, we think the Fastly::Services::Versions resource makes sense, we're still investigating how we can automate the activation of the version.

If you have requests for more CloudFormation resources in the future, in addition to submitting them here, I encourage you to also speak to the partners (Fastly, CloudFlare, etc) as well so that they're aware of your demand for them. That will help fuel collaboration on both sides.

AndrewBarba commented 1 year ago

Awesome that's great to hear. And if you look at the other resources I asked for they all rely on a version so I think the version resource sets us up nicely for everything after.

And yes activating the version seemed tricky, I wasn't sure how that plays with the CF model / what special case would be needed for that.

LucasQChen commented 1 year ago

For my knowledge, if we don't have a good way to automate the activation, the version resource type will still be useful for your use case, right?

AndrewBarba commented 1 year ago

Activating the version is definitely critical, but I won't stop you from working on the Version resource. Wondering if we could have an additional Fastly::Services::ActivateVersion resource thats basically always the last thing defined and fully controls activating the version. This would also make activation opt in and give people more control if for some reason they dont want to activate a version right away

LucasQChen commented 1 year ago

Discussed with the team and we're planning to add both a Version and ActiveVersion resource. The ActiveVersion resource will behave how you described, it will deactivate the existing version and activate a new version. Also we deviated from calling it ActivateVersion and will call it ActiveVersion because we typically name resource types as nouns instead of verbs.

Development on both of these will start soon. I'll provide more updates here.

LucasQChen commented 1 year ago

Quick update: PR is up and being reviewed https://github.com/aws-ia/cloudformation-fastly-resource-providers/pull/54

After it's merged, we'll work on publishing these to the CloudFormation Registry.

LucasQChen commented 1 year ago

We're happy to announce Fastly::Service::ActiveVersion and Fastly::Service::Version resources are now available for use in the Registry! Please give it a try and let us know if anyone has any feedback.

We'll go ahead and close this issue.

AndrewBarba commented 1 year ago

Awesome thank you. Do you have docs on using those as well?

LucasQChen commented 1 year ago

Here you go:

https://github.com/aws-ia/cloudformation-fastly-resource-providers/tree/main/Fastly-Services-ActiveVersion/docs/README.md https://github.com/aws-ia/cloudformation-fastly-resource-providers/blob/main/Fastly-Services-Version/docs/README.md

AndrewBarba commented 1 year ago

Yup just read these, makes sense! Will test these out and open new issue if needed. Thanks a ton

AndrewBarba commented 1 year ago

@CloudChoom We're close but other resources depend on versionId: string and they need to be converted to versionId: number

Example on Backend:

CDN Fastly::Services::Backend UPDATE_FAILED Properties validation failed for resource apibackend with message:
#/VersionId: expected type: String, found: Integer
LucasQChen commented 1 year ago

The team is looking into this and planning the fix as we speak.

LucasQChen commented 1 year ago

@AndrewBarba the versionId type mistmatch issue should be resolved now for the other resources.