amazon-ssm-agent service fails connecting to SSM due to eventual consistency#503
Closed
gnought wants to merge 6 commits intohashicorp:mainfrom
Closed
amazon-ssm-agent service fails connecting to SSM due to eventual consistency#503gnought wants to merge 6 commits intohashicorp:mainfrom
gnought wants to merge 6 commits intohashicorp:mainfrom
Conversation
98a5b76 to
f630f5c
Compare
f630f5c to
ffbf88b
Compare
ffbf88b to
7aba92c
Compare
7aba92c to
28f2951
Compare
28f2951 to
0b70ffc
Compare
0b70ffc to
f65f504
Compare
ec03a6e to
3efe077
Compare
3efe077 to
1cf9371
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using the below sample config. the
temporary_iam_instance_profile_policy_documentmay not be immediately visible after a EC2 instance starts due to eventual consistency ofPutRolePolicyandAddRoleToInstanceProfile. As a result, theamazon-ssm-agentservice may fail to connect to SSM because the required SSM role does not available yet. This issue requires logging into the instance to manually restart the service or wait for 30 mins to self heal. (please see the packer log and ec2 amazon-ssm-agent log below)This PR automatically creates a custom instance profile associated with
AmazonSSMManagedInstanceCoremanaged policy whensession_manageris used without specifyingiam_instance_profilekey attribute. If a user definestemporary_iam_instance_profile_policy_document, it will be added as an inline policy to the custom profile. This will solve the racing condition ensuring theamazon-ssm-agentservice could consistently connect to SSM on the first start.As a bonus, this PR also supports AWS China region, closing #50
sample config
packer build log:
The ec2 amazon-ssm-agent log: