Closed14

m1 docker で awscli を使う

tkttkt
FROM hashicorp/terraform:0.12.21

RUN apk upgrade
RUN apk add curl unzip jq less git

RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
RUN unzip awscliv2.zip
RUN ./aws/install
RUN rm awscliv2.zip



ENTRYPOINT [ "/bin/sh", "-c" ]
tkttkt
Step 6/8 : RUN ./aws/install
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
 ---> Running in 915eb31d1af5
./aws/install: line 78: /aws/dist/aws: not found
You can now run: /usr/local/bin/aws --version
/bin/sh: aws: not found

こんな感じに怒られる

tkttkt

install の中に色々入っているので、それをいじるのはめんどくさそう
aws の docker image が動くのか先に試してみる

tkttkt

terraform のほうを直接入れてみよう

tkttkt
FROM amazon/aws-cli

RUN yum install -y yum-utils
RUN yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
RUN yum -y install terraform


ENTRYPOINT [ "/bin/sh", "-c" ]
bash-4.2# yum install terraform
Loaded plugins: ovl, priorities
https://rpm.releases.hashicorp.com/RHEL/2/aarch64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.


 One of the configured repositories failed (Hashicorp Stable - aarch64),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=hashicorp ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable hashicorp
        or
            subscription-manager repos --disable=hashicorp

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=hashicorp.skip_if_unavailable=true

failure: repodata/repomd.xml from hashicorp: [Errno 256] No more mirrors to try.
https://rpm.releases.hashicorp.com/RHEL/2/aarch64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
tkttkt
docker-compose.yml
version: "3.7"
services:
  terraform:
    image: hashicorp/terraform:0.12.21
    working_dir: /src
    entrypoint: ["/bin/sh", "-c"]
    environment:
      AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
      AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
      AWS_DEFAULT_REGION: ap-northeast-1
    volumes:
      - .:/src

環境変数をちゃんと渡してあげれば動く

tkttkt

(途中で起きてたエラーは解決してないけど、)やりたいことはできたのでよし

tkttkt
config.fish
alias aws "docker run --rm -it -v ~/.aws:/root/.aws -v (pwd):/aws -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_DEFAULT_REGION amazon/aws-cli"

これでもよき

このスクラップは2021/01/14にクローズされました