AWS SQS
AWS SQS
이 알림 서비스는 AWS SQS 큐로 간단한 메시지를 보내요. 큐 이름·리전·계정·엔드포인트를 설정하고, 자격 증명은 Secret을 참조하거나 AWS 환경 변수로 주입할 수 있어요. FIFO 큐로 보낼 때는 messageGroupId를 템플릿에 포함해야 해요.
출처: 문서
본문
파라미터 (Parameters)
이 알림 서비스는 AWS SQS 큐로 간단한 메시지를 보낼 수 있어요.
queue— 메시지를 보내려는 큐 이름. 대상(destination) 어노테이션으로 덮어쓸 수 있어요.region— sqs 큐의 리전. env 변수AWS_DEFAULT_REGION으로도 제공할 수 있어요.key— 선택 사항, aws access key는 변수를 통한 시크릿 참조 또는 env 변수AWS_ACCESS_KEY_ID로 제공해야 해요.secret— 선택 사항, aws access secret은 변수를 통한 시크릿 참조 또는 env 변수AWS_SECRET_ACCESS_KEY로 제공해야 해요.account— 선택 사항, 큐의 외부 accountIdendpointUrl— 선택 사항, localstack 개발에 유용
예시 (Example)
Secret으로 자격 증명 가져오기 (Using Secret for credential retrieval):
리소스 어노테이션:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
annotations:
notifications.argoproj.io/subscribe.on-deployment-ready.awssqs: "overwrite-myqueue"
ConfigMap:
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.awssqs: |
region: "us-east-2"
queue: "myqueue"
account: "1234567"
key: "$awsaccess_key"
secret: "$awsaccess_secret"
template.deployment-ready: |
message: |
Deployment {{.obj.metadata.name}} is ready!
trigger.on-deployment-ready: |
- when: any(obj.status.conditions, {.type == 'Available' && .status == 'True'})
send: [deployment-ready]
- oncePer: obj.metadata.annotations["generation"]
Secret:
apiVersion: v1
kind: Secret
metadata:
name: <secret-name>
stringData:
awsaccess_key: test
awsaccess_secret: test
AWS 환경 변수를 사용하는 최소 설정 (Minimal configuration using AWS Env variables)
다음 환경 변수 목록이 OIDC나 다른 방법으로 주입되도록 보장하세요. 그리고 SQS가 계정 안에 로컬로 있다고 가정해요. 민감 데이터에 Secret을 쓰는 것을 생략하고 다른 파라미터도 생략할 수 있어요. (ConfigMap으로 파라미터를 설정하는 게 우선돼요.)
변수:
export AWS_ACCESS_KEY_ID="test"
export AWS_SECRET_ACCESS_KEY="test"
export AWS_DEFAULT_REGION="us-east-1"
리소스 어노테이션:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
annotations:
notifications.argoproj.io/subscribe.on-deployment-ready.awssqs: ""
ConfigMap:
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.awssqs: |
queue: "myqueue"
template.deployment-ready: |
message: |
Deployment {{.obj.metadata.name}} is ready!
trigger.on-deployment-ready: |
- when: any(obj.status.conditions, {.type == 'Available' && .status == 'True'})
send: [deployment-ready]
- oncePer: obj.metadata.annotations["generation"]
FIFO SQS 큐 (FIFO SQS Queues)
FIFO 큐는 모든 메시지와 함께 MessageGroupId를 보내야 해요. 같은 MessageGroupId를 가진 메시지는 순서대로 하나씩 처리돼요.
FIFO SQS 큐로 보내려면 아래 예시처럼 템플릿에 messageGroupId를 포함해야 해요.
template.deployment-ready: |
message: |
Deployment {{.obj.metadata.name}} is ready!
messageGroupId: {{.obj.metadata.name}}-deployment