@Dhamodharan Actually, nowadays, we primarily deploy containerized applications on EKS or ECS clusters.
The deployment strategy you are working on is old school, but it still works for small projects without strict requirements for downtime, availability and etc.
From a security perspective, I like your second approach - with ssm command.
Just be aware that IAM user behind the AWS creds have minimum permissions - ideally just to run ssm command for specific resource.
Also, you can check GHA OIDC auth on AWS that will generate short-live AWS creds for each run and will be restricted to specific IAM role with required permissions.
You can read more here
https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services
Cloudposse also have open sourced terraform modules to provision all required resources for such auth method.