Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions eventbridge-schedule-to-ec2-terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ resource "aws_subnet" "subnet" {

data "aws_ami" "amazon-linux-2" {
most_recent = true
owners = ["amazon"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


filter {
name = "owner-alias"
values = ["amazon"]
}

filter {
name = "name"
name = "name"
values = ["amzn2-ami-hvm*"]
}
}
Expand Down Expand Up @@ -129,7 +125,6 @@ resource "aws_iam_policy" "scheduler_ec2_policy" {

resource "aws_iam_role" "scheduler-ec2-role" {
name = "scheduler-ec2-role"
managed_policy_arns = [aws_iam_policy.scheduler_ec2_policy.arn]

assume_role_policy = jsonencode({
Version = "2012-10-17"
Expand All @@ -145,3 +140,8 @@ resource "aws_iam_role" "scheduler-ec2-role" {
]
})
}

resource "aws_iam_role_policy_attachment" "scheduler_ec2_policy_attachment" {
role = aws_iam_role.scheduler-ec2-role.name
policy_arn = aws_iam_policy.scheduler_ec2_policy.arn
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: The managed_policy_arns argument is already deprecated. I update code correctly😀 See document below.