Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@voronenko-p
Created May 29, 2019 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voronenko-p/89332b544e571819c25c100aaeb40a68 to your computer and use it in GitHub Desktop.
Save voronenko-p/89332b544e571819c25c100aaeb40a68 to your computer and use it in GitHub Desktop.
data "aws_route53_zone" "acme" {
name = "_acme-challenge.staging.yourdomain.com."
}
resource "aws_iam_policy" "allow_writing_acme_zone" {
# ... other configuration ...
name = "allow_writing_staging_acme_zone"
policy = "${data.aws_iam_policy_document.allow_writing_acme_zone.json}"
}
data "aws_iam_policy_document" "allow_writing_acme_zone" {
statement {
actions = ["route53:ChangeResourceRecordSets"]
resources = ["arn:aws:route53:::hostedzone/${data.aws_route53_zone.acme.zone_id}"]
effect = "Allow"
}
statement {
actions = ["route53:GetHostedZone"]
resources = ["arn:aws:route53:::hostedzone/${data.aws_route53_zone.acme.zone_id}"]
effect = "Allow"
}
statement {
actions = ["route53:ListResourceRecordSets"]
resources = ["arn:aws:route53:::hostedzone/${data.aws_route53_zone.acme.zone_id}"]
effect = "Allow"
}
statement {
actions = ["route53:ChangeResourceRecordSets"]
resources = ["arn:aws:route53:::hostedzone/${data.aws_route53_zone.acme.zone_id}"]
effect = "Allow"
}
statement {
actions = ["route53:GetChange"]
resources = ["*"]
effect = "Allow"
}
statement {
actions = ["route53:ListHostedZones"]
resources = ["*"]
effect = "Allow"
}
}
resource "aws_iam_user" "acme-writer" {
name = "acme-domain-writer"
}
resource "aws_iam_user_policy_attachment" "acme-writer-policy" {
user = "${aws_iam_user.acme-writer.name}"
policy_arn = "${aws_iam_policy.allow_writing_acme_zone.arn}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment