FormidableLabs / terraform-aws-serverless

Infrastructure support for Serverless framework apps, done the right way
https://registry.terraform.io/modules/FormidableLabs/serverless/aws
MIT License
144 stars 19 forks source link

Migrate to TF 12 #67

Closed kevinmstephens closed 4 years ago

kevinmstephens commented 4 years ago

Copy of previous PR that was accidentally merged to master then reverted. See original here: https://github.com/FormidableLabs/terraform-aws-serverless/pull/65

Fixes #55

Run the automated 0.12upgrade terraform script in each module.

Testing: This is tested through the aws-lambda-serverless-reference app pointed at a local version of this branch. A plan shows no changes with the updated code.

If you already have these repos cloned it might be good in aws-lambda-serverless-reference to delete .terraform folder to make sure you have a clean local state.

Clone both repos, check out the TF 12 upgrade branches, and run tf init then plan.

git clone git@github.com:FormidableLabs/terraform-aws-serverless.git && \
cd terraform-aws-serverless && \
git checkout feat/terraform-12-upgrade && \
cd .. \
git clone git@github.com:FormidableLabs/aws-lambda-serverless-reference.git && \
cd aws-lambda-serverless-reference && \
git checkout feat/terraform-12-upgrade && \
tfenv install 0.12.18 && tfenv use 0.12.18 && \
STAGE=sandbox aws-vault exec FIRST.LAST --no-session -- \
yarn tf:service:init --reconfigure && \
STAGE=sandbox aws-vault exec FIRST.LAST --no-session -- \
yarn tf:service:plan
stevenmusumeche commented 4 years ago

I ran the commands you provided, and tf:service:plan appears to work and I get "No changes" at the end. However, I also get a permissions error, which I am not sure is related, but thought I'd mention it here:


No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.
✨  Done in 9.95s.
yarn run v1.19.1
$ yarn run tf:terraform init $(yarn -s tf:service:_backend) $(yarn -s tf:service:_vars) --reconfigure
$ eval $(yarn -s env) && cd terraform && terraform init -backend-config=bucket=cf-simple-reference-sandbox-terraform-state -backend-config=dynamodb_table=cf-simple-reference-sandbox-terraform-locks -backend-config=region=us-east-1 -var region=us-east-1 -var service_name=simple-reference -var stage=sandbox --reconfigure
Initializing modules...

Initializing the backend...

Successfully configured the backend "s3"! Terraform will automatically
use this backend unless the backend configuration changes.
Error refreshing state: AccessDenied: Access Denied
    status code: 403, request id: 55CC1A223A821FC7, host id: p9LHuwmBM6H+CBG3Md58Rabtd7j68Yo1hYXh1mp4hIkWcRtLz+oeXQOU8Fj7Mywq/4stLvX36bo=
ryan-roemer commented 4 years ago

@stevenmusumeche Thanks for kicking the tires! I'll do Kevin's steps above this morning and see if I can reproduce your error.

CumpsD commented 4 years ago

I just wanted to let you guys know I just learned about your project and it looks amazing! I've been running our infrastructure on Terraform for a while now (https://github.com/informatievlaanderen/aws-infrastructure) and for a new serverless project, I'll be going with your great module. When we're up and running I'll try to contribute as well :)

:+1:

kevinmstephens commented 4 years ago

@stevenmusumeche @ryan-roemer I setup the test again and using my admin user ran yarn tf:service:init and yarn tf:service:plan without problems. Not able to reproduce your problem. @stevenmusumeche which user did you use to run this?