Skip to content

eventbridge-schedule-to-ec2-terraform: Fix "Most Recent Image Not Filtered" error#2916

Merged
parikhudit merged 2 commits intoaws-samples:mainfrom
kakakakakku:eventbridge-schedule-to-ec2-terraform
Mar 30, 2026
Merged

eventbridge-schedule-to-ec2-terraform: Fix "Most Recent Image Not Filtered" error#2916
parikhudit merged 2 commits intoaws-samples:mainfrom
kakakakakku:eventbridge-schedule-to-ec2-terraform

Conversation

@kakakakakku
Copy link
Copy Markdown
Contributor

Issue #, if available:
N/A

Description of changes:
Hi😀 Thanks for the useful patterns!

While testing eventbridge-schedule-to-ec2-terraform, I occurred Most Recent Image Not Filtered error. And more I noticed that the managed_policy_arns argument is already deprecated.

╷
│ Error: Most Recent Image Not Filtered
│ 
│   with data.aws_ami.amazon-linux-2,
│   on main.tf line 35, in data "aws_ami" "amazon-linux-2":
│   35: data "aws_ami" "amazon-linux-2" {
│ 
│ "most_recent" is set to "true" and results are not filtered by owner or image ID. With this configuration, a third party may introduce a new image which will be returned by this data source. Filter by owner or image
│ ID to avoid this possibility.
╵
"managed_policy_arns" is deprecated

Check

terraform apply completed successfully and it works good with updating cron schedule for quick testing.

image image

Thank you😀


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

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
Copy Markdown
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.


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

Choose a reason for hiding this comment

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

@parikhudit parikhudit merged commit de99291 into aws-samples:main Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants