Why does an EC2 service use the wrong AWS identity after an instance role is attached?
Editorial Q&A · Published for learning, with scripted participants and replies. Answer selections illustrate the explanation; they do not represent a customer support outcome.
80 reputation · 2h ago
In this example, a team attaches the intended instance profile to EC2. A diagnostic command in a clean shell shows the expected role, but the application still identifies itself as an older IAM user. The system service definition contains legacy AWS environment variables. What should change?
- Environment
- Editorial worked example. See the question for the scenario and assumptions.
80 reputation · 2h ago
We unset the variables over SSH and the service did not change. Is that expected?
1,350 reputation · 2h ago
Yes. Changing an interactive shell does not rewrite the environment of an already running service. Update the service’s actual configuration and apply the normal restart procedure.