开始学习 Ansible 并希望简化ansible-galaxy search nginx命令,但我得到:
ERROR! Unknown error when attempting to call Galaxy at 'https://galaxy.ansible.com/api/api': <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)>
Run Code Online (Sandbox Code Playgroud)
曾尝试使用ansible-galaxy --ignore-certs search nginx但ansible-galaxy -c search nginx现在正在寻找ansible-galaxy: error: unrecognized arguments: --ignore-certs摊位。
操作系统:
发行商 ID:Ubuntu 描述:Ubuntu 18.04.5 LTS 版本:18.04 代号:bionic
安斯波版本:
ansible 2.9.5
config file = /home/maciej/projects/priv/ansible_nauka/packt_course/ansible.cfg
configured module search path = ['/home/maciej/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/maciej/.local/lib/python3.6/site-packages/ansible
executable location = /home/maciej/.local/bin/ansible
python version = 3.6.9 (default, Jul …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Pydantic 编写一个验证器来处理以下字符串(示例):
1.1.0, 3.5.6, 1.1.2等。
我失败了以下语法:
install_component_version: constr(regex=r"^[0-9]+.[0-9]+.[0-9]$")
install_component_version: constr(regex=r"^([0-9])+.([0-9])+.([0-9])$")
install_component_version: constr(regex=r"^([0-9])\.([0-9])\.([0-9])$")
Run Code Online (Sandbox Code Playgroud)
谁能帮我看看正则表达式语法应该是什么样子?
这部分存储桶策略如何写成 aws_iam_policy_document?
"Condition": {
"StringEquals": {
"s3:x-amz-acl": "bucket-owner-full-control",
"aws:SourceAccount": "xxxxxxxxxxxx"
},
"ArnLike": {
"aws:SourceArn": "arn:aws:s3:::my-tf-test-bucket"
}
Run Code Online (Sandbox Code Playgroud)
和
condition {
test = "StringEquals"
values = []
variable = ""
}
Run Code Online (Sandbox Code Playgroud)
帮助 :)。
我想知道如何从以下输出中访问该值:
output "backend_tg_arn" {
value = var.backend_tg_needed ? aws_lb_target_group.backend_tg[*].arn : null
}
Run Code Online (Sandbox Code Playgroud)
它是用以下代码生成的:
resource "aws_lb_target_group" "backend_tg" {
count = var.backend_tg_needed ? 1 : 0
name = "${var.client_code}-${var.environment}-backend-tg"
port = var.backend_port
protocol = "HTTP"
target_type = var.backend_target_type
vpc_id = aws_vpc.main_vpc.id
}
Run Code Online (Sandbox Code Playgroud)
上面的输出作为变量传递给另一个模块:
backend_tg_arn = module.network.backend_tg_arn
Run Code Online (Sandbox Code Playgroud)
我试图将其分配给 alb 侦听器的默认操作:
default_action {
type = "forward"
target_group_arn = var.backend_tg_arn
}
}
Run Code Online (Sandbox Code Playgroud)
出现错误:
var.backend_tg_arn 是有 1 个元素的元组
属性“target_group_arn”的值不合适:需要字符串。
我正在努力如何访问这个arn值...它应该通过某种循环来完成,但无法弄清楚。
我正在使用 Terraform 创建私有子网:
resource "aws_subnet" "private" {
count = length(data.aws_availability_zones.available.names)
vpc_id = aws_vpc.main_vpc.id
cidr_block = cidrsubnet(var.vpc_cidr, 8, count.index + 10)
availability_zone = element(data.aws_availability_zones.available.names, count.index)
map_public_ip_on_launch = false
tags = {
Name = "${var.client_code}-${var.environment}-private-${element(data.aws_availability_zones.available.names, count.index)}"
}
}
Run Code Online (Sandbox Code Playgroud)
后来我尝试使用以下命令创建 SSM 参数:
resource "aws_ssm_parameter" "private_subnets_ids" {
name = "/${var.client_code}-${var.environment}/backend/SUBNET_IDS"
type = "StringList"
value = aws_subnet.private.*.id
}
Run Code Online (Sandbox Code Playgroud)
由于子网资源正在创建三个子网,因此会引发以下错误:
4: value = aws_subnet.private.*.id
|----------------
| aws_subnet.private is tuple with 3 elements
Inappropriate value for attribute "value": string required.
Run Code Online (Sandbox Code Playgroud)
我应该如何将这个三元素元组传递给StringList类型参数?
Powershell 中的第一步。我无法AWSPowerShell 从 AWS 安装的模块中删除/卸载模块。\nGet-Module -Name AWSPowerShell,AWSPowerShell.NetCore,AWS.Tools.Common -ListAvailable显示如下:
Directory: C:\\Users\\user\\Documents\\PowerShell\\Modules\n\nModuleType Version PreRelease Name PSEdition ExportedCommands\n---------- ------- ---------- ---- --------- ----------------\nBinary 4.1.14.0 AWS.Tools.Common Core,Desk {Clear-AWSHistory, Set-AWSHistoryConfiguration, Initialize-AWSDefaultConfi\xe2\x80\xa6\n\n Directory: C:\\Program Files (x86)\\AWS Tools\\PowerShell\n\nModuleType Version PreRelease Name PSEdition ExportedCommands\n---------- ------- ---------- ---- --------- ----------------\nBinary 3.3.509.0 AWSPowerShell Desk\nRun Code Online (Sandbox Code Playgroud)\n我试图通过以下方式卸载它,但Uninstall-Module -Name AWSPowerShell出现错误:
Uninstall-Package: C:\\program files\\powershell\\7\\Modules\\PowerShellGet\\PSModule.psm1:12733\n Line |\n12733 | \xe2\x80\xa6 $null = PackageManagement\\Uninstall-Package @PSBoundParameters\n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n | No match was found for the specified search criteria and module …Run Code Online (Sandbox Code Playgroud) 我收到以下错误:
此 CDK CLI 与您的应用程序使用的 CDK 库不兼容。请将 CLI 升级到最新版本。(云组装架构版本不匹配:支持的最大架构版本是 8.0.0,但发现是 9.0.0)
发出cdk diff命令后。
我确实运行了,npm install -g aws-cdk@latest之后我成功安装了新版本的软件包:Successfully installed aws-cdk.assets-1.92.0 aws-cdk.aws-apigateway-1.92.0 aws-cdk.aws-apigatewayv2-1.92.0 ... etc. 和pip install -r requirements.txt
但是打字后cdk --version我仍然得到1.85.0 (build 5f44668).
我的部分setup.py如下:
install_requires=[
"aws-cdk.core==1.92.0",
"aws-cdk.aws-ec2==1.92.0",
"aws-cdk.aws_ecs==1.92.0",
"aws-cdk.aws_elasticloadbalancingv2==1.92.0"
],
Run Code Online (Sandbox Code Playgroud)
我现在卡住了,因为将软件包降级setup.py到 1.85.0 throwing ImportError: cannot import name 'CapacityProviderStrategy' from 'aws_cdk.aws_ecs'。
帮助:),我想使用最新的软件包版本。
学习AWS CDK(来自terraform)。我目前正在努力,如何编写一段代码将允许我创建重定向,如下图所示:

到目前为止我拥有的代码:
class LoadBalancer(core.Construct):
def __init__(self, scope: core.Construct, construct_id: str, props):
super().__init__(scope, construct_id)
self.props = props
def load_balancer(self, security_group, fargate_service, arn_certificates_list):
load_balancer = alb.ApplicationLoadBalancer(
self,
"TestFargateALB",
vpc=self.props["vpc"],
deletion_protection=True if self.props["environment"].lower() == "prod" else False,
http2_enabled=True,
internet_facing=True,
security_group=security_group
)
load_balancer.set_attribute(key="routing.http.drop_invalid_header_fields.enabled", value="true")
http_load_balancer_listener = load_balancer.add_listener(
'http_listener', port=80, open=False
)
https_load_balancer_listener = load_balancer.add_listener(
"https_listener", port=443, open=False, certificate_arns=arn_certificates_list
)
https_target_group = https_load_balancer_listener.add_targets(
'ecs_target_group',
targets=[fargate_service],
port=80,
protocol=alb.ApplicationProtocol.HTTP,
deregistration_delay=core.Duration.seconds(amount=10)
)
https_target_group.configure_health_check(
healthy_http_codes="200,301,302",
healthy_threshold_count=3,
interval=core.Duration.seconds(10),
timeout=core.Duration.seconds(5),
unhealthy_threshold_count=5,
path="/"
)
http_load_balancer_listener.add_action(
'DefaultAction',
action=alb.ListenerAction(action_json=alb.CfnListener.ActionProperty(
type="redirect",
redirect_config=alb.CfnListener.RedirectConfigProperty(
status_code="HTTP_301",
host="#{host}", …Run Code Online (Sandbox Code Playgroud) python ×3
terraform ×3
aws-cdk ×2
amazon-iam ×1
amazon-s3 ×1
ansible ×1
aws-application-load-balancer ×1
powershell ×1
pydantic ×1
ssl ×1
ubuntu-18.04 ×1