AWS::CloudFormation::Authentication - AWS CloudFormation

AWS::CloudFormation::Authentication

AWS::CloudFormation::Authentication 리소스를 사용하여 AWS::CloudFormation::Init 리소스로 지정하는 파일 또는 소스의 인증 자격 증명을 지정합니다.

AWS::CloudFormation::Init로 지정하는 파일 또는 소스의 인증 정보를 포함하려면 소스가 URI인 경우 uris 속성을 사용하고 소스가 Amazon S3 버킷인 경우 buckets 속성을 사용합니다. 파일에 대한 자세한 내용은 파일 단원을 참조하십시오. 소스에 대한 자세한 내용은 소스 단원을 참조하십시오.

직접 AWS::CloudFormation::Init 리소스에서 파일에 대한 인증 정보를 지정할 수도 있습니다. 리소스의 파일 키에는 authentication이라는 이름의 속성이 포함됩니다. authentication 속성을 사용하여 리소스에서 정의된 인증 정보를 파일과 직접 연결할 수 있습니다.AWS::CloudFormation::Authentication

파일의 경우 AWS CloudFormation은 다음과 같은 순서로 인증 정보를 찾습니다.

  1. authentication AWS::CloudFormation::Init 키의 files 속성입니다.

  2. uris 리소스의 buckets 또는 AWS::CloudFormation::Authentication 속성입니다.

소스의 경우 CloudFormation은 AWS::CloudFormation::Authentication리소스의 uris 또는 buckets 속성에서 인증 정보를 찾습니다.

명령문

CloudFormation 템플릿에서 이 객체를 선언하려면 다음 구문을 사용합니다.

AWS::CloudFormation::Authentication 유형을 사용하는 경우에는 다음 사항을 반드시 숙지해야 합니다.

  • 대부분의 CloudFormation 리소스와는 달리, AWS::CloudFormation::Authentication 유형에는 Properties라는 블록이 포함되지 않으며, 그 대신 각각 고유의 인증 속성이 들어 있는 사용자가 이름을 지정한 블록의 목록이 포함됩니다.

    모든 속성이 각 인증 유형과 관련되는 것은 아닙니다. 세부 정보는 유형 속성을 참조하십시오.

  • 대부분의 CloudFormation 리소스와 다르게 속성 이름에 Camel 소문자를 사용합니다.

JSON

{ "Type" : "AWS::CloudFormation::Authentication" { "String" : { "accessKeyId" : String, "buckets" : [ String, ... ], "password" : String, "secretKey" : String, "type" : String, "uris" : [ String, ... ], "username" : String, "roleName" : String } } }

YAML

Type: AWS::CloudFormation::Authentication String: accessKeyId: String buckets: - String password: String secretKey: String type: String uris: - String username: String roleName: String

속성

accessKeyId

S3 인증에 대한 액세스 키 ID를 지정합니다.

필수 항목 여부: 조건부. type 속성을 "S3"로 설정한 경우에만 지정할 수 있습니다.

타입: 문자열

buckets

S3 인증 자격 증명과 연결할 쉼표로 구분된 Amazon S3 버킷 목록입니다.

필수 항목 여부: 조건부. type 속성을 "S3"로 설정한 경우에만 지정할 수 있습니다.

유형: 문자열 값의 목록

password

기본 인증에 대한 암호를 지정합니다.

필수 항목 여부: 조건부. type 속성을 "basic"으로 설정한 경우에만 지정할 수 있습니다.

타입: 문자열

secretKey

S3 인증에 대한 비밀 키를 지정합니다.

필수 항목 여부: 조건부. type 속성을 "S3"로 설정한 경우에만 지정할 수 있습니다.

타입: 문자열

type

인증 스키마에 사용자 이름과 암호를 사용할지("basic") 또는 액세스 키 ID와 비밀 키를 사용할지("S3")를 지정합니다.

"basic"을 지정할 경우 username, passworduris 속성을 지정합니다.

"S3"를 지정할 경우 accessKeyId, secretKeybuckets(선택 사항) 속성을 지정합니다.

필수 항목 여부: 예

유효한 값: basic | S3

uris

기본 인증 자격 증명과 연결할 쉼표로 구분된 URI 목록입니다. 권한 부여는 지정된 URI 및 더 구체적인 URI에 적용됩니다. 예를 들어, http://www.example.com을 지정할 경우 http://www.example.com/test에 권한 부여도 적용됩니다.

필수 항목 여부: 조건부. type 속성을 "basic"로 설정한 경우에만 지정할 수 있습니다.

유형: 문자열 값의 목록

username

기본 인증을 위한 사용자 이름을 지정합니다.

필수 항목 여부: 조건부. type 속성을 "basic"으로 설정한 경우에만 지정할 수 있습니다.

타입: 문자열

roleName

역할 기반 인증에 대한 역할을 설명합니다.

중요

EC2 인스턴스에 연결된 인스턴스 프로파일 내에 이 역할이 꼭 포함되어야 합니다. 인스턴스 프로파일은 하나의 IAM 역할만 포함할 수 있습니다.

필수 항목 여부: 조건부. type 속성을 "S3"로 설정한 경우에만 지정할 수 있습니다.

유형: 문자열입니다.

예제

참고

대부분의 리소스와는 달리, AWS::CloudFormation::Authentication 유형은 Camel 소문자 이름을 사용하는 인증 속성이 포함된 각각에 사용자가 이름을 지정한 블록의 목록을 지정합니다.

EC2 웹 서버 인증

이 템플릿 코드 조각은 EC2 인스턴스 내의 프라이빗 S3 버킷에서 파일을 가져오는 방법을 보여 줍니다. 인증에 사용되는 자격 증명은 AWS::CloudFormation::Authentication 리소스에서 정의되며 파일 섹션의 AWS::CloudFormation::Init 리소스에서 참조됩니다.

JSON

"WebServer": { "Type": "AWS::EC2::Instance", "DependsOn" : "BucketPolicy", "Metadata" : { "AWS::CloudFormation::Init" : { "config" : { "packages" : { "yum" : { "httpd" : [] } }, "files" : { "/var/www/html/index.html" : { "source" : { "Fn::Join" : [ "", [ "http://s3.amazonaws.com/", { "Ref" : "BucketName" }, "/index.html" ] ] }, "mode" : "000400", "owner" : "apache", "group" : "apache", "authentication" : "S3AccessCreds" } }, "services" : { "sysvinit" : { "httpd" : { "enabled" : "true", "ensureRunning" : "true" } } } } }, "AWS::CloudFormation::Authentication" : { "S3AccessCreds" : { "type" : "S3", "accessKeyId" : { "Ref" : "CfnKeys" }, "secretKey" : { "Fn::GetAtt": [ "CfnKeys", "SecretAccessKey" ] } } } }, "Properties": { EC2 Resource Properties ... } }

YAML

WebServer: Type: AWS::EC2::Instance DependsOn: "BucketPolicy" Metadata: AWS::CloudFormation::Init: config: packages: yum: httpd: [] files: /var/www/html/index.html: source: Fn::Join: - "" - - "http://s3.amazonaws.com/" - Ref: "BucketName" - "/index.html" mode: "000400" owner: "apache" group: "apache" authentication: "S3AccessCreds" services: sysvinit: httpd: enabled: "true" ensureRunning: "true" AWS::CloudFormation::Authentication: S3AccessCreds: type: "S3" accessKeyId: Ref: "CfnKeys" secretKey: Fn::GetAtt: - "CfnKeys" - "SecretAccessKey" Properties: EC2 Resource Properties ...

기본 및 S3 인증 모두 지정

다음 예제 템플릿 코드 조각에는 basicS3 인증 유형이 모두 포함됩니다.

JSON

"AWS::CloudFormation::Authentication" : { "testBasic" : { "type" : "basic", "username" : { "Ref" : "UserName" }, "password" : { "Ref" : "Password" }, "uris" : [ "example.com/test" ] }, "testS3" : { "type" : "S3", "accessKeyId" : { "Ref" : "AccessKeyID" }, "secretKey" : { "Ref" : "SecretAccessKeyID" }, "buckets" : [ "DOC-EXAMPLE-BUCKET1" ] } }

YAML

AWS::CloudFormation::Authentication: testBasic: type: "basic" username: Ref: "UserName" password: Ref: "Password" uris: - "example.com/test" testS3: type: "S3" accessKeyId: Ref: "AccessKeyID" secretKey: Ref: "SecretAccessKeyID" buckets: - "myawsbucket"

IAM 역할

다음 예제에서는 IAM 역할을 사용하는 방법을 보여줍니다.

  • myRoleAWS::IAM::Role 리소스입니다.

  • cfn-init를 실행하는 Amazon EC2 인스턴스는 인스턴스 프로파일을 통해 myRole과 연결됩니다.

  • 예제에서는 Amazon S3 인증과 마찬가지로 buckets 속성을 사용하여 인증을 지정합니다. 이름별로 인증을 지정할 수도 있습니다.

JSON

"AWS::CloudFormation::Authentication": { "rolebased" : { "type": "S3", "buckets": [ "myBucket" ], "roleName": { "Ref": "myRole" } } }

YAML

AWS::CloudFormation::Authentication: rolebased: type: "S3" buckets: - "myBucket" roleName: Ref: "myRole"