我的 terraform 文件中有一个模块,该模块创建了一些执行一些操作的数据库服务器。
首先,它创建一个自动缩放组以使用特定图像,然后创建一些 EBS 卷并附加它们,然后添加一些 lambda 代码,以便在启动实例时注册到路由 53。所以总共有大约 80 行文本。
提炼
module "systemt-sql-db01" {
source = "localmodules/tf-aws-asg"
name = "${var.envname}-sys-db01"
envname = "${var.envname}"
service = "dbpx"
ami_id = "${data.aws_ami.app_sqlproxy.id}"
user_data = "${data.template_cloudinit_config.config-enforcement-sqlproxy.rendered}"
#subnets = ["${module.subnets-enforcement.web_private_subnets}"]
subnets = ["${element(module.subnets-enforcement.web_private_subnets, 1)}"]
security_groups = ["${aws_security_group.unfiltered-egress-sg.id}", "${aws_security_group.sysopssg.id}", "${aws_security_group.system-sqlproxy.id}"]
key_name = "${var.keypair}"
load_balancers = ["${var.envname}-enf-dbpx-int-elb"]
iam_instance_profile = "${module.iam_profile_generic.profile_arn}"
instance_type = "${var.enforcement_instancesize_dbpx}"
min = 0
max = 0
}
Run Code Online (Sandbox Code Playgroud)
然后我有两个参数文件,一个在启动预生产时调用,另一个在启动生产时调用。我不希望这些包含变量以外的任何内容。
问题是对于生产我需要调用模块两次,但对于生产我需要调用它三次。
人们谈论模块的计数功能,但我认为目前还不可能。任何人都可以建议任何其他方法来做到这一点?我想要的是能够在我的参数文件中设置所有 DB ASG 名称的列表变量,然后每次循环调用该模块。
我希望这是有道理的?
谢谢你
我想将现有的terraform模板(hcl)转换为aws cloudformation模板(json/yaml).
我基本上想通过CFN_NAG找到这些模板的安全问题.
我已经尝试过的方法是将HCL转换为JSON,然后将模板传递给CFN_NAG,但由于两个模板具有不同的结构,因此我收到了失败.
有人可以在这提供任何建议吗?
我在Docker上运行React内置的应用程序.我正在寻找一种调试它的方法.我正在使用Visual Studio Code.这是我的Docker文件和Docker-compose文件
FROM node:boron
ARG build_env
RUN mkdir /usr/share/unicode && cd /usr/share/unicode && wget ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
COPY package.json /tmp/package.json
RUN cd /tmp && npm install
COPY ./shim/RelayDefaultNetworkLayer.js /tmp/node_modules/react-relay/lib/RelayDefaultNetworkLayer.js
COPY ./shim/buildRQL.js /tmp/node_modules/react-relay/lib/buildRQL.js
RUN mkdir -p /var/www && cp -a /tmp/node_modules /var/www/
WORKDIR /var/www
COPY . ./
RUN if [ "$build_env" != "development" ]; then npm run build-webpack && npm run gulp; fi
EXPOSE 8080
CMD ["npm", "run", "--debug=5858 prod"]
Run Code Online (Sandbox Code Playgroud)
我的docker-compose文件看起来像
version: '2'
services:
nginx:
container_name: nginx
image: openroad/nginx
build:
context: nginx …Run Code Online (Sandbox Code Playgroud) 我创建了一个包,包含Pipfile,我想用 docker 进行测试。
我想用 pip 安装用 Pipfile 编写的包,而不创建 virutalenv。
# (do something to create some-file)
RUN pip install (some-file)
Run Code Online (Sandbox Code Playgroud)
怎么做?
我正在尝试创建加密的 S3 存储桶。执行 terraform apply 后,一切看起来都不错,但是当我查看 AWS 控制台中的存储桶时,它并未加密。我也知道上一个问题。
这是我的 terraform 版本:
Terraform v0.11.13
+ provider.aws v2.2.0
Run Code Online (Sandbox Code Playgroud)
这是我的 tf 文件:
resource "aws_s3_bucket" "test-tf-enc" {
bucket = "test-tf-enc"
acl = "private"
tags {
Name = "test-tf-enc"
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我执行命令后的输出:
aws_s3_bucket.test-tf-enc: Creating...
acceleration_status: "" => "<computed>"
acl: "" => "private"
arn: "" => "<computed>"
bucket: "" => "test-tf-enc"
bucket_domain_name: "" => "<computed>"
bucket_regional_domain_name: "" => "<computed>"
force_destroy: "" => …Run Code Online (Sandbox Code Playgroud) 根据aws validate-template,我做了测试,以验证URL和本地文件中的相同模板.
但我得到了不同的输出.
直接从URL测试:
$ aws cloudformation validate-template --template-url https://s3.amazonaws.com/cloudformation-templates-us-east-1/S3_Bucket.template
{
"Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters": []
}
Run Code Online (Sandbox Code Playgroud)
但是当我将它下载到本地时,再次测试.
$ wget https://s3.amazonaws.com/cloudformation-templates-us-east-1/S3_Bucket.template
2014-12-16 14:48:27 (11.1 MB/s) - 'S3_Bucket.template' saved [652/652]
$ aws cloudformation validate-template --template-body S3_Bucket.template
A client error (ValidationError) occurred …Run Code Online (Sandbox Code Playgroud) 我想在 CircleCI 的环境变量中使用文件的内容。这可能吗?到目前为止,我在我的 Circle.yml 中尝试过这个
machine:
environment:
AMI_DESCRIPTION: "$(cat DESCRIPTION.TXT)"
dependencies:
override:
- echo "DESC $AMI_DESCRIPTION"
Run Code Online (Sandbox Code Playgroud)
但运行时,它只输出:
echo "DESC $AMI_DESCRIPTION"
DESC
Run Code Online (Sandbox Code Playgroud)
我也尝试添加
deployment:
production:
branch: master
commands:
- ./packer/packer build -var 'ami_desc="$(cat DESCRIPTION.TXT)"' template.json
Run Code Online (Sandbox Code Playgroud)
但“ami_desc”仍然是空的。
据我所知,使用 s3fs 挂载 s3 存储桶的唯一方法是使用accesskey:secretkey支持各种文件位置的文件中的指定。
但是,如果我是 ec2 实例,在本地 s3 帐户中,具有实例配置文件,我只想使用可用的实例配置文件凭据。有谁知道使用实例配置文件的方法,而不必在本地文件系统中设置凭据?如果没有,是否有人致力于支持此功能?
谢谢
我正在尝试部署使用 terraform 的自定义授权方的 API Gateway REST API。
自定义授权方使用现有的 lambda 函数。
resource "aws_api_gateway_authorizer" "accountprofileauth" {
name = "auth"
rest_api_id = "${aws_api_gateway_rest_api.accountprofileapi.id}"
authorizer_uri = "arn:aws:lambda:us-east-2:XXXX:function:dev-authorizer"
identity_source = "method.request.header.Authorization"
type = "REQUEST"
}
Run Code Online (Sandbox Code Playgroud)
当我应用 terraform 时,出现以下错误
* aws_api_gateway_authorizer.accountprofileauth: Error creating API Gateway Authorizer: BadRequestException: Invalid Authorizer URI: arn:aws:lambda:us-east-2:XXXX:function:dev-authorizer. Authorizer URI should be a valid API Gateway ARN that represents a Lambda function invocation.
status code: 400, request id: XXXX
Run Code Online (Sandbox Code Playgroud)
lambda 函数存在并且工作正常。当我使用无服务器部署时,相同的 arn 工作正常。
您知道格式/提供有效 arn 的示例吗?
谢谢。
我是 terraform 的新手,并试图解决测试模块时遇到的一个小问题。
以下是我本地计算机中的文件夹结构。
我在存储文件夹级别有以下代码
#-------storage/main.tf
provider "aws" {
region = "us-east-1"
}
resource "aws_s3_bucket" "my-first-terraform-bucket" {
bucket = "first-terraform-bucket"
acl = "private"
force_destroy = true
}
Run Code Online (Sandbox Code Playgroud)
以下是引用存储模块的 main_code 级别的片段
#-------main_code/main.tf
module "storage" {
source = "../storage"
}
Run Code Online (Sandbox Code Playgroud)
当我从存储文件夹发出 terraform init / plan / apply 时,它工作得非常好,并且 terraform 创建了 s3 存储桶。
但是当我从 main_code 文件夹中尝试相同的操作时,我收到以下错误 -
main_code@DFW11-8041WL3: terraform init
Initializing modules...
- module.storage
Error downloading modules: Error loading modules: module storage: No Terraform configuration files found in directory: .terraform/modules/0d1a7f4efdea90caaf99886fa2f65e95
Run Code Online (Sandbox Code Playgroud)
我已经阅读了 Stack Overflow …