【发布时间】:2021-09-07 16:57:08
【问题描述】:
在 terraform 中使用 AWS 会话令牌。 RDS 恢复需要一个多小时,同时会话令牌会过期。因此,tf 状态文件也没有在 s3 中更新。有没有办法在后台运行 tf apply 以便我们可以定期刷新令牌并且操作不会失败?
11:07:25 status code: 400, request id: PF3V9137RT1HVB3W, host id: SeXwAFlokygO5NjyKppBD/kYvFl/i9nrh81YSf7Szta6y5Wfd20ssxmFYYwhg+XysuPMvb1uuJo=
11:07:25
11:07:25
11:07:25 Error: Failed to persist state to backend.
11:07:25
11:07:25 The error shown above has prevented Terraform from writing the updated state
11:07:25 to the configured backend. To allow for recovery, the state has been written
11:07:25 to the file "errored.tfstate" in the current working directory.
11:07:25
11:07:25 Running "terraform apply" again at this point will create a forked state,
11:07:25 making it harder to recover.
11:07:25
11:07:25 To retry writing this state, use the following command:
11:07:25 terraform state push errored.tfstate
11:07:25
11:07:25
11:07:25
11:07:25 Releasing state lock. This may take a few moments...
11:07:30
11:07:30 Error releasing the state lock!
11:07:30
11:07:30 Error message: failed to retrieve lock info: ExpiredTokenException: The security token included in the request is expired
11:07:30 status code: 400, request id: C7JE11FDGLPTU672G4781LOR73VV4KQNSO5AEMVJF66Q9ASUAAJG
【问题讨论】:
-
一种选择是延长最大会话持续时间。在 IAM 方面,您可以将角色的最长会话持续时间设置为 12 小时,然后在 terraform AWS 提供商配置中,您可以在 AWS 提供商的假设角色配置块中设置 duration_seconds 参数。
-
@Jenneth 是的,我有这个选项,但它当前使用的角色也被其他一些服务使用,我希望能提出替代解决方案,而不是创建新角色.
标签: amazon-web-services session terraform token amazon-rds