AWS SQS
AWS SQS 큐에 간단한 메시지를 보낼 수 있는 알림 서비스예요.
출처: 문서
본문
파라미터 (Parameters)
이 알림 서비스는 AWS SQS 큐에 간단한 메시지를 보낼 수 있어요.
queue- 메시지를 보내려는 큐의 이름이에요. 대상(타깃) destination 어노테이션으로 덮어쓸 수 있어요region- sqs 큐의 리전으로, 환경 변수 AWS_DEFAULT_REGION으로 제공할 수 있어요key- 선택 사항이에요. aws access key는 반드시 시크릿의 변수를 참조하거나 환경 변수 AWS_ACCESS_KEY_ID를 통해 제공해야 해요secret- 선택 사항이에요. aws access secret은 반드시 시크릿의 변수를 참조하거나 환경 변수 AWS_SECRET_ACCESS_KEY를 통해 제공해야 해요account- 선택 사항이에요. 큐의 외부 accountId예요endpointUrl- 선택 사항이에요. localstack으로 개발할 때 유용해요
예제 (Example)
자격 증명 조회에 Secret 사용하기 (Using Secret for credential retrieval)
리소스 어노테이션 (Resource Annotation):
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: argo-rollouts-notification-configmap
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가 해당 계정(account)에 로컬이라고 가정해요. 민감 데이터에 대해 secret 사용을 생략하고 다른 파라미터를 생략해도 돼요. (ConfigMap으로 파라미터를 설정하면 우선해요.)
변수 (Variables):
export AWS_ACCESS_KEY_ID="test"
export AWS_SECRET_ACCESS_KEY="test"
export AWS_DEFAULT_REGION="us-east-1"
리소스 어노테이션 (Resource Annotation):
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: argo-rollouts-notification-configmap
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 큐는 모든 메시지와 함께 MessageGroupId가 전송되어야 해요. 같은 MessageGroupId를 가진 메시지는 순서대로 하나씩 처리돼요.
FIFO SQS Queue로 보내려면 아래 예제처럼 템플릿에 messageGroupId를 포함해야 해요.
template.deployment-ready: |
message: |
Deployment {{.obj.metadata.name}} is ready!
messageGroupId: {{.obj.metadata.name}}-deployment