-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathia-codedeploy.tf
More file actions
62 lines (50 loc) · 1.46 KB
/
ia-codedeploy.tf
File metadata and controls
62 lines (50 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
resource "aws_codedeploy_app" "ia-codedeploy-app" {
compute_platform = "Server"
name = "ia-codedeploy-app"
}
data "aws_iam_policy_document" "assume_role" {
statement {
effect = "Allow"
principals {
type = "Service"
identifiers = ["codedeploy.amazonaws.com"]
}
actions = ["sts:AssumeRole"]
}
}
resource "aws_iam_role" "codepipeline_role" {
name = "codepipeline_iam_role"
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}
resource "aws_iam_role_policy_attachment" "AWSCodeDeployRole" {
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSCodeDeployRole"
role = aws_iam_role.codepipeline_role.name
}
resource "aws_sns_topic" "ia-topic" {
name = "ia-topic"
}
resource "aws_codedeploy_deployment_group" "ia-codedeploy-group" {
app_name = aws_codedeploy_app.ia-codedeploy-app.name
deployment_group_name = "ia-codedeploy-group"
service_role_arn = aws_iam_role.codepipeline_role.arn
ec2_tag_set {
ec2_tag_filter {
key = "Name"
type = "KEY_AND_VALUE"
value = "ia-main-server"
}
}
trigger_configuration {
trigger_events = ["DeploymentFailure"]
trigger_name = "ia-trigger"
trigger_target_arn = aws_sns_topic.ia-topic.arn
}
auto_rollback_configuration {
enabled = true
events = ["DEPLOYMENT_FAILURE"]
}
alarm_configuration {
alarms = ["my-alarm-name"]
enabled = true
}
}