Skip to content

Commit 7065ff6

Browse files
committed
Deploy SQS queue for crates.io to staging
The SQS queue that was configured in #377 has been deployed to the new staging account for crates.io that was created in #374. Slight modifications were necessary to the configuration: - The resource and human-readable names of the SQS are now identical. - The `sid` for policies matches the naming rules of AWS. - The input variable has been changed, since the account number is not part of a bucket's ARN and can thus not be extracted from it. The infrastructure has been deployed with the same version of the Terraform provider for AWS as the other modules in simpleinfra to ensure future compatibility.
1 parent bbab800 commit 7065ff6

File tree

5 files changed

+78
-22
lines changed

5 files changed

+78
-22
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"aws": {
3+
"profile": "crates-io-staging",
4+
"region": "us-east-2"
5+
}
6+
}

terragrunt/accounts/crates-io-staging/crates-io-logs/.terraform.lock.hcl

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
terraform {
2+
source = "../../../..//terragrunt/modules/crates-io-logs"
3+
}
4+
5+
include {
6+
path = find_in_parent_folders()
7+
merge_strategy = "deep"
8+
}
9+
10+
inputs = {
11+
bucket_account = 890664054962
12+
bucket_arn = "arn:aws:s3:::rust-staging-crates-io-logs"
13+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
terraform {
2+
required_version = "~> 1"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = "~> 4.32"
8+
}
9+
}
10+
}
11+
12+
variable "bucket_account" {
13+
type = number
14+
description = "Account ID of the S3 bucket which will send events to the SQS queue"
15+
}
16+
17+
variable "bucket_arn" {
18+
type = string
19+
description = "ARN of the S3 bucket which will send events to the SQS queue"
20+
}
Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
resource "aws_sqs_queue" "log_event_queue" {
2-
name = "cdn-log-queue"
1+
resource "aws_sqs_queue" "cdn_log_event_queue" {
2+
name = "cdn-log-event-queue"
33
receive_wait_time_seconds = 20
44
}
55

66
resource "aws_sqs_queue_policy" "s3_push" {
7-
queue_url = aws_sqs_queue.log_event_queue.id
7+
queue_url = aws_sqs_queue.cdn_log_event_queue.id
88
policy = data.aws_iam_policy_document.s3_push_to_queue.json
99
}
1010

1111
data "aws_iam_policy_document" "s3_push_to_queue" {
1212
statement {
13-
sid = "allow-s3-to-push-events"
13+
sid = "AllowS3ToPushEvents"
1414
effect = "Allow"
1515
principals {
1616
type = "Service"
@@ -19,45 +19,37 @@ data "aws_iam_policy_document" "s3_push_to_queue" {
1919

2020
actions = ["sqs:SendMessage"]
2121

22-
resources = [aws_sqs_queue.log_event_queue.arn]
22+
resources = [aws_sqs_queue.cdn_log_event_queue.arn]
2323
condition {
2424
test = "ArnLike"
2525
variable = "aws:SourceArn"
26-
values = [data.aws_arn.src_bucket.arn]
26+
values = [var.bucket_arn]
2727
}
2828
condition {
2929
test = "StringEquals"
3030
variable = "aws:SourceAccount"
31-
values = [data.aws_arn.src_bucket.account]
31+
values = [var.bucket_account]
3232
}
3333
}
3434
}
3535

36-
data "aws_arn" "src_bucket" {
37-
arn = var.src_log_bucket_arn
38-
}
39-
40-
variable "src_log_bucket_arn" {
41-
type = string
42-
description = "Bucket ARN which will send events to the SQS queue"
43-
}
44-
4536
resource "aws_iam_user" "heroku_access" {
4637
name = "crates-io-heroku-access"
4738
}
4839

4940
resource "aws_iam_access_key" "crates_io" {
50-
user = aws_iam_user.heroku_access
41+
user = aws_iam_user.heroku_access.name
5142
}
5243

53-
resouce "aws_iam_user_policy" "sqs_read" {
54-
name = "heroku-access"
55-
user = aws_iam_user.heroku_access.name
44+
resource "aws_iam_user_policy" "sqs_read" {
45+
name = "heroku-access"
46+
user = aws_iam_user.heroku_access.name
47+
policy = data.aws_iam_policy_document.heroku_access.json
5648
}
5749

5850
data "aws_iam_policy_document" "heroku_access" {
5951
statement {
60-
sid = "allow-sqs"
52+
sid = "AllowAccessToSQS"
6153
effect = "Allow"
6254

6355
actions = [
@@ -67,6 +59,6 @@ data "aws_iam_policy_document" "heroku_access" {
6759
"sqs:ReceiveMessage",
6860
]
6961

70-
resources = [aws_sqs_queue.log_event_queue.arn]
62+
resources = [aws_sqs_queue.cdn_log_event_queue.arn]
7163
}
7264
}

0 commit comments

Comments
 (0)