SNSトピック"handson-cli-lambda-topic"を構築します。
作業に必要なパラメータを変数に格納をします。
0. リージョンの指定
リージョンを指定します。
環境変数の設定 export AWS_DEFAULT_REGION='ap-northeast-1'
環境変数の設定
export AWS_DEFAULT_REGION='ap-northeast-1'
1. SNSトピック名
SNSトピック名を指定します。
変数の設定: SNS_TOPIC_NAME='handson-cli-lambda-topic'
変数の設定:
SNS_TOPIC_NAME='handson-cli-lambda-topic'
各変数に正しいパラメータ値が格納されていることを確認します。
変数の確認: cat << END # 0. AWS_DEFAULT_REGION:"ap-northeast-1" AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION}" # 1. SNS_TOPIC_NAME:"handson-cli-lambda-topic" SNS_TOPIC_NAME="${SNS_TOPIC_NAME}" END
変数の確認:
cat << END # 0. AWS_DEFAULT_REGION:"ap-northeast-1" AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION}" # 1. SNS_TOPIC_NAME:"handson-cli-lambda-topic" SNS_TOPIC_NAME="${SNS_TOPIC_NAME}" END
SNSトピックを構築します。
変数の確認: cat << END # SNS_TOPIC_NAME:"handson-cli-lambda-topic" SNS_TOPIC_NAME="${SNS_TOPIC_NAME}" END コマンド: aws sns create-topic \ --name ${SNS_TOPIC_NAME} 結果(例): { "TopicArn": "arn:aws:sns:ap-northeast-1:XXXXXXXXXXXX:handson-cli-lambda-topic" }
cat << END # SNS_TOPIC_NAME:"handson-cli-lambda-topic" SNS_TOPIC_NAME="${SNS_TOPIC_NAME}" END
コマンド:
aws sns create-topic \ --name ${SNS_TOPIC_NAME}
結果(例):
{ "TopicArn": "arn:aws:sns:ap-northeast-1:XXXXXXXXXXXX:handson-cli-lambda-topic" }
SNSトピック"handson-cli-lambda-topic"が存在することを確認します。
コマンド: aws sns list-topics \ --query "Topics[?contains(TopicArn, \`${SNS_TOPIC_NAME}\`)].TopicArn" \ --output text 結果(例): arn:aws:sns:ap-northeast-1:XXXXXXXXXXXX:handson-cli-lambda-topic
aws sns list-topics \ --query "Topics[?contains(TopicArn, \`${SNS_TOPIC_NAME}\`)].TopicArn" \ --output text
arn:aws:sns:ap-northeast-1:XXXXXXXXXXXX:handson-cli-lambda-topic