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

AWS Amplify Console Resources #6917

Closed
mwarkentin opened this issue Dec 19, 2018 · 39 comments · Fixed by #11938
Closed

AWS Amplify Console Resources #6917

mwarkentin opened this issue Dec 19, 2018 · 39 comments · Fixed by #11938
Labels
new-resource Introduces a new resource. service/amplify Issues and PRs that pertain to the amplify service.
Milestone

Comments

@mwarkentin
Copy link
Contributor

mwarkentin commented Dec 19, 2018

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

AWS announced AWS Amplify Console at reinvent 2018.

AWS Amplify Console is a continuous deployment and hosting service for modern web applications with serverless backends. Modern web applications include single page app frameworks like React, Angular, and Vue, and static-site generators like Jekyll, Hugo, and Gatsby.

New or Affected Resource(s)

Here are some possible resources:

  • aws_amplify_console_app
  • aws_amplify_console_branch
  • aws_amplify_console_domain_association

References

Related PRs

@bflad bflad added new-resource Introduces a new resource. service/amplify Issues and PRs that pertain to the amplify service. labels Dec 19, 2018
@paulca99
Copy link

Do we know if there's any progress on this, or if it's even made it into the roadmap ?

@ladas-larry
Copy link

Hi, any progress with this one?

@larryboymi
Copy link

larryboymi commented Oct 7, 2019

So it looks like the ability to connect with amplify has been added to the provider codebase (in #9874), I guess now we await if anyone PR's the resources mentioned above?

@k24d
Copy link
Contributor

k24d commented Feb 2, 2020

Hi, I experimentally implemented the following resources:

  • aws_amplify_app
  • aws_amplify_backend_environment
  • aws_amplify_branch
  • aws_amplify_domain_association
  • aws_amplify_webhook

After adding validations and tests, I'll make a PR. Any comments are welcome.

@k24d
Copy link
Contributor

k24d commented Feb 7, 2020

I opened the following PRs:

@heschlie
Copy link

heschlie commented Mar 6, 2020

Is there any news on this, things seem to have stalled out?

@k24d
Copy link
Contributor

k24d commented Mar 12, 2020

#11928 must be reviewed. What should I do for the next step?

@heschlie
Copy link

@k24d That's a good question, not sure who is supposed to be pinged but it looks like you have done the work to get the PR reviewed (though it is failing the tests?) so...

As an aside, thanks for putting this all together!

@k24d
Copy link
Contributor

k24d commented Mar 13, 2020

@heschlie Oh, right. The tests failed because of broken documentation. I have fixed it now.

Hi @bflad, I'd like to get #11928 reviewed. What should I do?

@Gowiem
Copy link

Gowiem commented Apr 17, 2020

Hey @bflad @k24d -- Sorry to bug you folks, but is there anything we can do to help move this forward?

@k24d
Copy link
Contributor

k24d commented May 9, 2020

Please vote on #11928 by adding a 👍 reaction to help the community and maintainers prioritize the pull request.

@k24d
Copy link
Contributor

k24d commented May 10, 2020

I described how to build terraform-provider-aws with Amplify resources:

https://github.com/k24d/terraform-provider-aws/blob/amplify/README-amplify.md

Please try it and let me know if you have any problems.

@Gowiem
Copy link

Gowiem commented May 19, 2020

@k24d Great stuff! Thank you for putting the README together and all the hardwork on these new resources. I finally got a chance to check them out and they're working well for my use-cases.

I've got a pretty simple module put together that I'm using for some of my personal and business sites and planning on using for a client. You can check that out here: masterpointio/terraform-aws-amplify-app.

Regarding feedback, overall it seems super stable and well done, but here are a few things I noticed that I figure will be good items to tackle at some point:

  1. Basic Auth configuration where enable_basic_auth = false on the branch resource (possibly on the app resource as well) seems to always trigger an "update-in-place" apply. The resource thinks it needs to add the full basic_auth_config block to the resource every time. This is a common terraform problem that I've seen with a lot of resources, so I'm sure this category of problems is just a general PITA but I figured I should point it out. If you want an example of this, I'd be happy so show you.
  2. Similarly, the aws_amplify_domain_association resource seems to want to re-order the sub_domain_settings fields according to ordering of the Amplify console. So those configuration blocks always act as if they need an "update-in-place" apply as well.
  3. Lastly, when you create the Amplify App and corresponding branches on first apply, it does not trigger their initial build AFAICT. This causes the site to never goes live unless you go into the console and click the "Run build" CTA. I got around this by creating a webhook resource for each branch and then executing that webhook via local-exec (see here), but it would be awesome if the amplify resource or branch did that for me implicitly. Though maybe that should be up for discussion?

Anyway, again great work -- It's much appreciated! I'm stoked for when these resources finally land!

@k24d
Copy link
Contributor

k24d commented May 23, 2020

@Gowiem Thank you for your feedback!

  1. Right. Unfortunately, you have to delete the whole basic_auth_config block in order to disable it without diffs. I'll try to find a way to avoid the issue.

  2. I can't reproduce the issue. Could you give me an example?

  3. This is because AWS API, unlike Amplify Console, does not trigger builds just by creating resources. I think this is acceptable because the initial build is not a state. You can start the initial build by running aws amplify start-job. How about adding an example for the initial build in the document?

@Gowiem
Copy link

Gowiem commented May 24, 2020

@k24d 👍

  1. Yeah, knew it was a PITA for some reason. Good luck on finding a fix!

  2. This is reproducible using my module. The specific domain association resource is this one. It creates a consistent diff like this:
    image

  3. Sounds fine to me, I have my solution via the webhook method and that seems reasonable. Adding a note/example to kick off the first build as an update to the documentation would be great.

@Gowiem
Copy link

Gowiem commented Jun 12, 2020

@k24d Just on-boarded a client to use this module for a proof of concept, so one new question here:

  1. Do the AWS APIs allow for specifying the custom build image? I didn't see that in your docs on the resources, so I figured not. But I also wasn't able to find the AWS API docs for Amplify... Not sure what I'm missing there. Is there API documentation around the AWS Amplify resources or are you just going off of what is in the aws-sdk-go?

Also, side note for any watchers of this issue since the recently released AWS provider roadmap doesn't include merging this Amplify work: I created a Makefile for downloading the forked AWS provider that includes these resources. You can check that out here. Hoping that will help others use these resources prior to Terraform prioritizing this work.

@k24d
Copy link
Contributor

k24d commented Jun 13, 2020

@Gowiem You can use AWS CLI to examine how AWS implements a particular feature provided by AWS Management Console. In this case, it seems AWS uses the environment variable "_CUSTOM_IMAGE":

$ aws amplify list-apps
{
    "apps": [
        {
            "appId": "dmhvrv1x8jqg",
            ...
            "environmentVariables": {
                "_CUSTOM_IMAGE": "0123456789.dkr.ecr.us-west-2.amazonaws.com/amazonlinux:latest"
            },
        }
    ]
}

Can you try to set the same environment variable from Terraform?

@Gowiem
Copy link

Gowiem commented Jun 14, 2020

@k24d Aha interesting, thanks for the pointer. I'll give that a shot if it comes up again. I ended up putting together a somewhat ugly build_spec to get around not having custom image support, so I'm good for now.

As for others, I think it'd be a good call to mention how to supply a custom image in the Amplify App resource Docs.

@genert
Copy link

genert commented Jul 21, 2020

Any updates on this?

@Gowiem
Copy link

Gowiem commented Aug 14, 2020

Hey @k24d -- Just ran into a couple things and I thought I'd run it by you and see if you had any thoughts:

  1. I had previously set build_spec to some static YAML content for one of my projects, but now I want to use the build_spec.yml from the repo in question and AWS doesn't seem to want to use that if the build spec is set via the API / Console AFAICT. Therefore, I'm attempting to effectively remove setting the build_spec by setting aws_amplify_app's build_spec variable to null or "". I've attempted a few different ways, but all plans never result in the resource triggering an update. Is there something I'm missing there? Do I need to rebuild my amplify app to accomplish this? Bug or expected behavior?

  2. It seems that setting basic auth required on a branch does not extend to the PR previews against that branch. Is that possible or is that an ability that is lacking on the AWS / API side?

@k24d
Copy link
Contributor

k24d commented Aug 16, 2020

Hi @Gowiem

  1. Can you set build_spec to null or "" by using AWS CLI? I often noticed that many parameters cannot be set to "" because "" means "the parameter is missing", and the API does not change the existing value in that case. I couldn't find a way to clear the value. You need to recreate the entire Amplify App in this case.

  2. I'm not sure about that. Please try the same thing by AWS CLI.

@Gowiem
Copy link

Gowiem commented Sep 1, 2020

@k24d Yeah you're right on #1 -- Seems AWS doesn't allow this. Regarding #2, I needed to set the basic auth on the root project and not on the branches, which seems right. Your work allowed me to do that so all good there. Thanks again!

@Gowiem
Copy link

Gowiem commented Oct 28, 2020

Hey all, I've posted about this set of resources stalling out in the community forum, please share that around if you can so we can push these PRs forward!

https://discuss.hashicorp.com/t/terraform-provider-aws-what-can-be-done-to-move-the-aws-amplify-service-forward/16794

@k24d
Copy link
Contributor

k24d commented Oct 28, 2020

Hi all. A few months ago I received the following automated comment for #11928, which says some updates are required:

#11928 (comment)

However, I stopped using Amplify in my projects and I have no strong motivation to update these PRs. Is there anybody who can continue the work?

@Gowiem
Copy link

Gowiem commented Oct 28, 2020

@k24d Ah sorry to hear! I may have time in December / January to continue the work. I'll follow up then if I end up being able to take it on. I'm sure I'll have questions for you if so.

@ashishmohite
Copy link
Contributor

@k24d I can take this up.
I'm using Amplify in my current projects and right now we are using cloud formation resource to create it.
I would need a bit of help on getting started though

@k24d
Copy link
Contributor

k24d commented Oct 30, 2020

@Gowiem @ashishmohite Thanks. Feel free to ask me if you have any questions.

@ashishmohite
Copy link
Contributor

@k24d how do i fork your repo+branch ? I tried fork but it didn't bring the f-amplify-app branch

@k24d
Copy link
Contributor

k24d commented Oct 30, 2020

@ashishmohite The branch is in my fork repository. Please fetch the code from there.

# Your repository
% git clone https://github.com/terraform-providers/terraform-provider-aws.git
% cd terraform-provider-aws

# Fetch my fork
% git remote add k24d https://github.com/k24d/terraform-provider-aws.git
% git fetch k24d

# Create a new working branch
% git checkout -b f-amplify-app

# Merge my fork branch
% git merge k24d/f-amplify-app
CONFLICT (modify/delete): website/aws.erb deleted in HEAD and modified in k24d/f-amplify-app. Version k24d/f-amplify-app of website/aws.erb left in tree.
Auto-merging website/allowed-subcategories.txt
Auto-merging aws/provider.go
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your merge.renamelimit variable to at least 4501 and retry the command.
Automatic merge failed; fix conflicts and then commit the result.

# Resolve conflicts
% rm website/aws.erb
% git add website/aws.erb
% git merge --continue
[f-amplify-app 8f610bbf2] Merge remote-tracking branch 'k24d/f-amplify-app' into f-amplify-app

I'm not sure if this is the right way to resolve the conflict.

@ashishmohite
Copy link
Contributor

ashishmohite commented Nov 7, 2020

Fixed all the issues raised in automated comment for #11928

#15966

@k24d @Gowiem @bflad let me know what's the next step to get this moving

@k24d
Copy link
Contributor

k24d commented Nov 12, 2020

@ashishmohite Thanks! We just need to wait for the first view and feedbacks.

Once the PR for the aws_amplify_app resource has been accepted, we also need to update other resources, which I submited before:

#11936 [WIP] New Resource: aws_amplify_backend_environment
#11937 [WIP] New Resource: aws_amplify_branch
#11938 [WIP] New Resource: aws_amplify_domain_association
#11939 [WIP] New Resource: aws_amplify_webhook

@mwarkentin
Copy link
Contributor Author

@ashishmohite @k24d thanks for your work on this, really looking forward to having support for amplify console in Terraform. @bflad is there anyone available from the terraform team to review the PRs, or some sort of timeline on when that might happen?

@alona-shevliakova
Copy link

anticipating...

@mwarkentin
Copy link
Contributor Author

mwarkentin commented May 31, 2021

Looks like the first of those PRs was merged for the next release - @ewbankkit do you know if the others are on the near-term roadmap for review?

#11936

@ewbankkit
Copy link
Contributor

@mwarkentin Yes, we intend to review and merge all the outstanding Amplify Console PRs as part of the Roadmap task.

@ewbankkit
Copy link
Contributor

  • aws_amplify_app - Released in v3.43.0 of the Terraform AWS Provider
  • aws_amplify_backend_environment - Released in v3.43.0 of the Terraform AWS Provider
  • aws_amplify_branch - To be released in v3.44.0 of the Terraform AWS Provider
  • aws_amplify_domain_association - To be released in v3.44.0 of the Terraform AWS Provider
  • aws_amplify_webhook - To be released in v3.44.0 of the Terraform AWS Provider

@github-actions github-actions bot added this to the v3.44.0 milestone Jun 3, 2021
@mwarkentin
Copy link
Contributor Author

@ewbankkit thank you!!

@ghost
Copy link

ghost commented Jun 3, 2021

This has been released in version 3.44.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@github-actions
Copy link

github-actions bot commented Jul 4, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-resource Introduces a new resource. service/amplify Issues and PRs that pertain to the amplify service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.