flask-cognito-integration
flask-cognito-integration copied to clipboard
Deploy
When i deploy something i got this issue:
Error --------------------------------------------------
Error: The CloudFormation template is invalid: Template error: instance of Fn::GetAtt references undefined resource IamRoleLambdaExecution at /usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/lib/validateTemplate.js:20:13
Did you deploy the Terraform first (in infra?). The error could be down to a missing IAM Role. In this example those are defined in Terraform, and referenced from Serverless. Happy to help if you can provide more detail.
Thanks for the quick answer. If i run terraform init in the infra i am getting the next error:
terraform init -reconfigure
Initializing modules...
Initializing the backend... bucket The name of the S3 bucket
Enter a value: test-sandbox
key The path to the state file inside the bucket
Enter a value: test
region The region of the S3 bucket.
Enter a value: eu-west-1
Successfully configured the backend "s3"! Terraform will automatically use this backend unless the backend configuration changes.
Error: Failed to get existing workspaces: S3 bucket does not exist.
The referenced S3 bucket must have been previously created. If the S3 bucket was created within the last minute, please wait for a minute or two and try again.
Error: NoSuchBucket: The specified bucket does not exist status code: 404, request id: CB8431AAC013F897, host id: o8eTQVIatqrkbnKSL5SANAGsLFU+tFwYHIHtAmyReqSi020nnjYXMScPM3Ej9x6AzdNukBFY10k=
and if i run serverless deploy i see S3 gets deployed. So I do not understand what i need to deploy with terraform
So there's a step here somewhat implied but not fully stated. The code assumes there's already a terraform state file/table configured in S3. You don't have to do this for standalone stuff (with hindsight maybe I was overcomplicating things) but when you have multiple people working on stuff it ensures you don't get two people trying to make changes at once
https://www.terraform.io/docs/state/remote.html
That link should explain a little more about terraform states.
If i understand you right you please about the file:
_backend/sandbox.backend bucket = "f-consulting-sandbox-terraform-state" dynamodb_table = "terraform-lock" encrypt = true key = "flask-cognito/terraform.tfstate" region = "eu-west-1"
terraform init -reconfigure Initializing modules...
Initializing the backend... bucket The name of the S3 bucket
Enter a value: f-consulting-sandbox-terraform-state
key The path to the state file inside the bucket
Enter a value: flask-cognito/
region The region of the S3 bucket.
Enter a value: eu-west-1
Successfully configured the backend "s3"! Terraform will automatically use this backend unless the backend configuration changes.
Error: Failed to get existing workspaces: S3 bucket does not exist.
The referenced S3 bucket must have been previously created. If the S3 bucket was created within the last minute, please wait for a minute or two and try again.
Error: NoSuchBucket: The specified bucket does not exist status code: 404, request id: D1F0305308FF6850, host id: r03OhHf6rA02oMQud/WrOH6walC429F9/9Lb2kZ0G0VWv4SlcAgIKUPrunng2sNOuSZcJuybQ70=
But still this is not working. Can i comment it out so i can deploy and test the main code?
Yes, you should be able to comment this out and just have a local state file which will likely be all you need.
The process for creating an S3 state file looks like it's covered in this blog, https://blog.gruntwork.io/how-to-manage-terraform-state-28f5697e68fa so might be worth having a look at that if you're interested. It's not required to get this to work though.