Apple M1 Chip issues with Docker and Terraform
If you are using MAC for development on AWS, you might come across these issues. I am listing down a couple of hurdles I faced.
Docker Image Compatibility Issue
If you create a docker using a dockerfile and deploy it on to an ECS task, then the task would fail to start and keep failing with error: exec user process caused: exec format error
Basically it indicates that the docker image format is not compatible. In order to resolve this, Add the platform keyword on to the docker file.
FROM --platform=linux/x86-64 python
.
The solution was found from this thread: https://stackoverflow.com/questions/65942641/docker-image-built-on-mac-osx-wont-run-on-aws-ec2-instance
Strange Terraform Running Issue
It took some time for me to understand this issue. I installed the ARM version of Terraform on my Mac Pro, currently on Monterey. I initially installed the AMD 64 version of terraform on this machine, but it was thoring random runtime error and I moved to ARM version of terraform. It worked fine for simple resources nicely, but as I added a couple of more resources, I see it taking a long time to read the terraform state of different components. And while it is stuck reading the state, I found that the network connection goes away. I suspected my network initially, but finally found, when I stop the terraform script, my network connection is slowly coming back. Sometimes, I need to turn off the Wifi and turn it back on to resume the network connection.
I could find an older thread discussing about it:
It recommends disabling the IPv6, I tried it, but in vain.
It takes so long to complete : terraform plan or apply and sometimes never finish it.
I found no solution to this, I had to create an EC2 machine (ubuntu), install AWS CLI v2 and terraform for Linux as mentioned here:
Please note that both these issues do not occur on on an Intel Mac.