小编avi*_*amg的帖子

在bash脚本中将字符串转换为整数

在一个文本文件test.txt中,我有下一个信息:

sl-gs5 desconnected Wed Oct 10 08:00:01 EDT 2012 1001
Run Code Online (Sandbox Code Playgroud)

我想通过下一个命令行提取事件的小时:

hour=$(grep -n sl-gs5 test.txt | tail -1 | cut -d' ' -f6 | awk -F ":" '{print $1}')
Run Code Online (Sandbox Code Playgroud)

我得到了"08".当我尝试添加1时,

 14 echo $((hour+1))
Run Code Online (Sandbox Code Playgroud)

我收到下一条错误消息:

./test2.sh: line 14: 08: value too great for base (error token is "08")
Run Code Online (Sandbox Code Playgroud)

如果Bash中的变量是无类型的,为什么?

bash

34
推荐指数
3
解决办法
11万
查看次数

Terraform 上的“无效的旧提供程序地址”错误

我正在尝试使用 terraform v0.14.3 部署一个 bitbucket 管道以在谷歌云中创建资源。运行 terraform 命令后,管道失败并显示以下错误:

Error: Invalid legacy provider address

This configuration or its associated state refers to the unqualified provider
"google".

You must complete the Terraform 0.13 upgrade process before upgrading to later
versions.
Run Code Online (Sandbox Code Playgroud)

我们将 terraform 的本地版本更新为 v.0.13.0,然后运行:terraform 0.13upgrade如本指南中所述:https ://www.terraform.io/upgrade-guides/0-13.html 。生成的 versions.tf 文件需要 terraform 版本 >=0.13,我们所需的提供程序块现在如下所示:

terraform {
  backend "gcs" {
    bucket      = "some-bucket"
    prefix      = "terraform/state"
    credentials = "key.json" #this is just a bitbucket pipeline variable
  }
  required_providers {
    google = { …
Run Code Online (Sandbox Code Playgroud)

terraform bitbucket-pipelines terraform-provider-gcp

33
推荐指数
4
解决办法
2万
查看次数

本地状态无法被 terraform 上的另一个进程解锁

我的 terraform 远程状态和储物柜是在 aws 帐户下的 s3 和 dynamodb 上配置的,在 gitlab runner 上,某些计划任务已崩溃,在下一个执行计划中,会弹出以下错误:

Error: Error locking state: Error acquiring the state lock: ConditionalCheckFailedException:
The conditional request failed

Lock Info:
  ID:        <some-hash>
  Path:      remote-terrform-states/app/terraform.tfstate
  Operation: OperationTypePlan
  Who:       root@runner-abc-project-123-concurrent-0
  Version:   0.14.10
  Created:   2022-01-01 00:00:00 +0000 UTC
  Info:  some really nice info
Run Code Online (Sandbox Code Playgroud)

在尝试解锁此储物柜以便再次执行额外的执行计划时 - 我收到以下错误:

  terraform force-unlock <some-hash-abc-123>

  #output:
  Local state cannot be unlocked by another process
Run Code Online (Sandbox Code Playgroud)

我们如何释放这个地形储物柜?

amazon-dynamodb terraform tfstate locker

10
推荐指数
2
解决办法
2万
查看次数

无法下载 aws s3 冰川对象

我试图将 S3 存储桶中的所有文件复制到 VM 中的本地文件夹,但出现以下错误:

warning: Skipping file s3://bucket/object. Object is of storage class GLACIER.
Unable to perform download operations on GLACIER objects. You must restore the
object to be able to perform the operation. See aws s3 download help for
additional parameter options to ignore or force these transfers.
Run Code Online (Sandbox Code Playgroud)

冰川误差

要将文件从我的 S3 存储桶复制到本地文件夹,我使用了以下命令:

aws s3 cp s3://${s3Location} ${localDumpPath}
Run Code Online (Sandbox Code Playgroud)

在哪里:

  • ${s3Location} = 我的 s3 位置和
  • ${localDumpPath} = 我的本地文件夹路径

我需要更改什么才能成功复制?

amazon-s3 amazon-ec2 amazon-web-services amazon-glacier

2
推荐指数
2
解决办法
2067
查看次数

Terraform - 错误:插值表达式后出现额外字符

当我在Terraform aws_iam_policy_document上添加一些数据资源时,出现一些插值错误: Error: Extra characters after interpolation expression

这是代码块:

data "aws_iam_policy_document" "example_iam_policy_document" {

... // some statement
... // some other statement
... // some other statement
 
statement {
          actions   = [
              "ssm:TerminateSession"
          ]
          effect   = "Allow"
          resources = ["arn:aws:ssm:*:*:session/${aws:username}-*"]
      }
}
Run Code Online (Sandbox Code Playgroud)

语法有什么问题?

interpolation syntax-error terraform

2
推荐指数
1
解决办法
2361
查看次数