我在 terraform 中为 AWS 资源定义了一个策略,如下所示:
device-status-policy = <<EOF
{"Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iot:Connect", "Resource": "arn:aws:iot:us-west-2:foobaraccountid:client/device-status-qa*" }, { "Effect": "Allow", "Action": [ "iot:Publish", "iot:Receive", "iot:Subscribe" ] }
EOF
Run Code Online (Sandbox Code Playgroud)
我希望它的 Resource 部分是一个变量,就像这样(伪代码)
device-status-policy = <<EOF
{"Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iot:Connect", "Resource": "$SOMEVAR/device-status-qa*" }, { "Effect": "Allow", "Action": [ "iot:Publish", "iot:Receive", "iot:Subscribe" ] }
EOF
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏。谢谢。
按照此处的AWS 示例并引用balena.io 示例,我试图获取一个“事物”(当前是我 Mac 上的脚本)来更新 AWS 上的事物影子。
我越来越近了。到目前为止,我可以成功注册对事物影子的兴趣(更新:并订阅和发布到 MQTT 主题,接收更新)。但是,尝试更新阴影时出现超时。最初,由于事物证书上的政策缺失,我在注册兴趣时遇到了超时,现在是一个基本到位的政策。我目前的想法是,也许我需要使用不同的根 CA 证书(目前使用提供的 CA1),或者我的 base64 编码证书字符串有问题,编码为:
openssl base64 -in some-cert.pem -out some-cert.txt
#gets copied to clipboard and pasted in UI env field
pbcopy < some-cert.txt
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止所拥有的。请注意 TODO 说明,因为这是一项正在进行的工作。
政策(目前过于宽松):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iot:*",
"Resource": "*"
}
]
}
Run Code Online (Sandbox Code Playgroud)
故障排除.ts
// application endpoint
const AWS_ENDPOINT = "my-endpoint.iot.us-east-1.amazonaws.com";
// thing private key encoded in base64
const AWS_PRIVATE_CERT = "gets set in …Run Code Online (Sandbox Code Playgroud) 我一直在尝试在 AWS 上实施一项新策略,以允许特定用户管理特定安全组。我曾经可以使用此功能,但几周前它停止工作,现在无论我尝试什么,我都无法让它再次工作。
是否有人拥有有关如何创建策略以允许用户修改特定安全角色的有效 JSON 配置?这主要是为了允许某些用户在使用动态 IP 时更改防火墙规则。
编辑:这是我当前的 JSON 配置:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "s1",
"Effect": "Allow",
"Action": [
"ec2:DescribeInstanceAttribute",
"ec2:DescribeInstanceStatus",
"ec2:DescribeInstances",
"ec2:DescribeNetworkAcls",
"ec2:DescribeSecurityGroups"
],
"Resource": [
"*"
]
},
{
"Sid": "s2",
"Effect": "Allow",
"Action": [
"ec2:AuthorizeSecurityGroupEgress",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:RevokeSecurityGroupEgress",
"ec2:RevokeSecurityGroupIngress"
],
"Resource": [
"arn:aws:ec2:*:*:security-group/sg-<my id>"
]
}
]
Run Code Online (Sandbox Code Playgroud)
}
amazon-ec2 amazon-web-services aws-security-group aws-policies
我正在尝试使用 Terraform 在 AWS 中构建云基础设施。我想为 S3 存储桶添加一个策略,该策略通过templatefileterraform 的功能使用基于属性的授权 (ABAC)。我的问题是 terraform 和 AWS 使用的变量语法是相同的 ( ${...})。
这是策略模板:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowReadRole1",
"Action": [
"s3:GetObject"
],
"Resource": "arn:aws:s3:::${bucketName}/*",
"Effect": "Allow",
"Principal": "*",
"Condition": {
"s3:ExistingObjectTag/myid": "${aws:PrincipalTag/myid}"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
terrafrom 文件的相关部分是:
resource "aws_s3_bucket_policy" "mybuckets-policy" {
bucket = aws_s3_bucket.mybuckets[count.index].bucket
policy = templatefile("${path.module}/bucket-policy.json", {
bucketName = aws_s3_bucket.mybuckets[count.index].bucket
})
count = 2
}
Run Code Online (Sandbox Code Playgroud)
所以我想要的是${bucketName}模板的一部分被 terraform 替换,同时保留 AWS 表达式${aws:PrincipalTag/user-id}。但是在上面的配置上运行 terraform 会导致错误消息
调用函数“templatefile”失败:./bucket-policy.json:14,49-50:插值表达式后出现额外字符;期望用右大括号结束插值表达式,但发现了额外的字符。
如果我在模板中放置另一个项目${foobar} …
amazon-web-services terraform terraform-template-file terraform-provider-aws aws-policies
我正在尝试配置 AWS IoT 以与 AWS Amplify 一起使用。我总是看到错误为“ AMQJS0008I 套接字已关闭。 \xe2\x80\x9d 并且 CloudWatch 说 \xe2\x80\x9c AUTHORIZATION_FAILURE \xe2\x80\x9d。这是我配置的
\n\n {\n "Version": "2012-10-17",\n "Statement": [\n {\n "Sid": "VisualEditor0",\n "Effect": "Allow",\n "Action": [\n "cognito-identity:*",\n "mobileanalytics:PutEvents",\n "cognito-sync:*",\n "iot:Connect",\n "iot:Publish",\n "iot:Subscribe",\n "iot:Receive",\n "iot:GetThingShadow",\n "iot:UpdateThingShadow",\n "iot:DeleteThingShadow",\n "iot:AttachPolicy",\n "iot:AttachPrincipalPolicy"\n ],\n "Resource": "*"\n }\n ]\n }\nRun Code Online (Sandbox Code Playgroud)\n\n{\n "Version": "2012-10-17",\n "Statement": [\n {\n "Effect": "Allow",\n "Action": "iot:Connect",\n "Resource": "arn:aws:iot:ap-south-1:XXXXXXX:client/${iot:ClientId}"\n },\n {\n "Effect": "Allow",\n …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-cli aws-iot aws-amplify aws-policies