2

全部,

我正在尝试在 Fargate 上的 AWS ECS 计划任务上实施云托管解决方案。

我的Dockerfile样子:

FROM cloudcustodian/c7n:latest

WORKDIR /opt/src

COPY policy.yml policy.yml
COPY mailer.yml mailer.yml

ENTRYPOINT [ "/bin/sh" ]

policy.yml看起来像哪里

policies:
  - name: c7n-mailer-test
    resource: sqs
    filters:
     - "tag:MailerTest": absent
    actions:
      - type: notify
        template: default
        priority_header: '2'
        subject: testing the c7n mailer
        to:
          - test@mydomain.com
        transport:
          type: sqs
          queue: arn:aws:iam::xxxx:role/cloud-custodian-mailer-role-svc

mailer.yml长得像

queue_url: https://sqs.ap-southeast-1.amazonaws.com/xvxvxvx9/cloud-custodian
role: arn:aws:iam::xxxxx:role/cloud-custodian-mailer-role
from_address: test@mydomain.in

运行映像后,我在 SQS 或收件人的电子邮件中看不到任何消息。

另外,我怎样才能将输出存储在 s3 上。

4

1 回答 1

2

docker hub cloud custodian 上已经有官方 docker 镜像:https ://hub.docker.com/r/cloudcustodian/c7n

如果您想将工具与 custodian 一起使用,那么 docker hub Ex 上还提供了单独的 docker 映像。邮件:https ://hub.docker.com/r/cloudcustodian/mailer

但是,如果您想在同一个容器中运行两者,请查看:https ://github.com/harsh4870/cloud-custodian

Dockerfile

FROM python:3.6-alpine

LABEL MAINTAINER="Harsh Manvar <harsh.manvar111@gmail.com>"

WORKDIR /opt/src

COPY cloud-custodian .
RUN apk add --no-cache --virtual .build-deps gcc musl-dev
RUN pip install -r requirements.txt && \
    python setup.py install && \
    cd tools/c7n_mailer/ && \
    pip install -r requirements.txt && \
    pip install requests && \
    python setup.py install
RUN apk del .build-deps gcc musl-dev
WORKDIR /opt/src

COPY policy.yml policy.yml
COPY mailer.yml mailer.yml

ENTRYPOINT [ "/bin/sh" ]

通过传递命令运行 docker 镜像

docker run \
        -e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
        -e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
        -e AWS_DEFAULT_REGION="$(REGION)" \
        -v "$(CURDIR)/logs:/tmp" \
        "cloud-custodian:$(VERSION)" \
        -c "/usr/local/bin/custodian run -c policy.yml -s .; /usr/local/bin/c7n-mailer --config mailer.yml --run"
于 2020-02-09T12:52:39.500 回答