Skip to content

Commit

Permalink
Convert to terraform deploy
Browse files Browse the repository at this point in the history
Removed the use of cloudformation to rely on terraform instead.
To now deploy the stack, run:

  $ chalice package --pkg-format=terraform terraform
  $ cd terraform
  $ terraform apply
  • Loading branch information
kyleknap committed Jul 28, 2019
1 parent 42238fc commit 73bcfec
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 146 deletions.
9 changes: 8 additions & 1 deletion code/media-query/final/.chalice/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
"stages": {
"dev": {
"api_gateway_stage": "api",
"autogen_policy": false
"autogen_policy": false,
"environment_variables": {
"MEDIA_BUCKET_NAME": "${aws_s3_bucket.media_bucket.bucket}",
"MEDIA_TABLE_NAME": "${aws_dynamodb_table.media_table.name}",
"VIDEO_TOPIC_ARN": "${aws_sns_topic.video_topic.arn}",
"VIDEO_TOPIC_NAME": "${aws_sns_topic.video_topic.name}",
"VIDEO_ROLE_ARN": "${aws_iam_role.media_role.arn}"
}
}
}
}
41 changes: 0 additions & 41 deletions code/media-query/final/recordresources.py

This file was deleted.

104 changes: 0 additions & 104 deletions code/media-query/final/resources.json

This file was deleted.

64 changes: 64 additions & 0 deletions code/media-query/final/terraform/media-resources.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
resource "random_id" "resource_names" {
byte_length = 8
prefix = "media-query-"
}


resource "aws_s3_bucket" "media_bucket" {
bucket_prefix = "media-query"
}

resource "aws_dynamodb_table" "media_table" {
name = "${random_id.resource_names.dec}"
hash_key = "name"
attribute {
name = "name"
type = "S"
}
read_capacity = 5
write_capacity = 5
}


resource "aws_sns_topic" "video_topic" {
}

resource "aws_iam_role_policy" "media_policy" {
name = "media_policy"
role = "${aws_iam_role.media_role.id}"

policy = "${data.aws_iam_policy_document.allow_publish.json}"
}

resource "aws_iam_role" "media_role" {
name_prefix = "media-query-"

assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "rekognition.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}

data "aws_iam_policy_document" "allow_publish" {
statement {
actions = [
"sns:Publish",
]

resources = [
"${aws_sns_topic.video_topic.id}",
]

}
}

0 comments on commit 73bcfec

Please sign in to comment.