액세스 키 포기: 보안 엣지 및 온프렘 워크로드를 위한 IAM Roles Anywhere 구현
Source: Dev.to
위에 제공된 텍스트 외에 번역할 내용이 없습니다. 번역이 필요한 전체 텍스트를 제공해 주시면 한국어로 번역해 드리겠습니다.
How IAM Roles Anywhere Works
The service relies on a Public Key Infrastructure (PKI) chain:
- Trust Anchor – AWS에 신뢰할 인증 기관(CA)을 알려줍니다.
- Profile – 어떤 IAM 역할을 가정할 수 있는지와 기간을 정의합니다.
- Role –
rolesanywhere.amazonaws.com서비스 주체가 가정할 수 있도록 허용하는 신뢰 정책을 가진 IAM 역할.
AWS 리소스 배포
아래는 필요한 신뢰 앵커, IAM 역할 및 프로필을 생성하는 최소 CloudFormation 템플릿입니다. 환경에 맞게 이름, ARN 및 정책을 조정하십시오.
AWSTemplateFormatVersion: '2010-09-09'
Description: Deploy IAM Roles Anywhere for On‑Premise Workloads
Parameters:
CACertificateBody:
Type: String
Description: The PEM‑encoded public key of your Certificate Authority.
Resources:
EdgeTrustAnchor:
Type: AWS::RolesAnywhere::TrustAnchor
Properties:
Name: OnPremDataCenterAnchor
Enabled: true
Source:
SourceData:
X509CertificateData: !Ref CACertificateBody
SourceType: CERTIFICATE_BUNDLE
EdgeWorkloadRole:
Type: AWS::IAM::Role
Properties:
RoleName: EdgeBackupRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: rolesanywhere.amazonaws.com
Action:
- sts:AssumeRole
- sts:TagSession
- sts:SetSourceIdentity
Condition:
StringEquals:
"aws:PrincipalTag/x509Subject/OU": "DataCenter-Northeast"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonS3FullAccess # Scope as needed
EdgeProfile:
Type: AWS::RolesAnywhere::Profile
Properties:
Name: EdgeServerProfile
DurationSeconds: 3600 # 1‑hour temporary credentials
Enabled: true
RoleArns:
- !GetAtt EdgeWorkloadRole.Arn
온프레미스 서버 구성
- Certificate & Private Key – 신뢰 앵커로 업로드한 CA가 서명한 클라이언트 인증서와 개인 키를 획득합니다.
- AWS Signing Helper –
aws_signing_helper바이너리를 설치합니다 (AWS 제공). - Credential Process – 헬퍼를 호출하도록
~/.aws/config에 프로파일을 추가합니다.
[profile edge-workload]
credential_process = /usr/local/bin/aws_signing_helper credential-process \
--certificate /etc/pki/edge/server.crt \
--private-key /etc/pki/edge/server.key \
--trust-anchor-arn arn:aws:rolesanywhere:us-east-1:123456789012:trust-anchor/your-anchor-id \
--profile-arn arn:aws:rolesanywhere:us-east-1:123456789012:profile/your-profile-id \
--role-arn arn:aws:iam::123456789012:role/EdgeBackupRole
이 구성으로 edge-workload 프로파일을 사용하는 모든 애플리케이션은 자동으로 단기간 유효한 자격 증명을 받으며, 애플리케이션 자체가 IAM Roles Anywhere에 대해 알 필요가 없습니다.
샘플 애플리케이션 코드
import boto3
from botocore.exceptions import ClientError
def upload_to_s3(file_name: str, bucket: str) -> None:
"""Upload a file to S3 using the edge‑workload profile."""
session = boto3.Session(profile_name='edge-workload')
s3 = session.client('s3')
try:
s3.upload_file(file_name, bucket, file_name)
print(f"Successfully uploaded {file_name} using temporary credentials!")
except ClientError as e:
print(f"Upload failed: {e}")
if __name__ == "__main__":
upload_to_s3('daily_backup.tar.gz', 'my-secure-onprem-backups')
혜택
- Zero Static Secrets – 엣지 서버가 손상되더라도 디스크에 AWS 키가 남아 있지 않습니다.
- Instant Revocation – CA에서 클라이언트 인증서를 즉시 폐기하면 IAM 변경 없이 접근이 차단됩니다.
- Auditability – 각 자격 증명 요청은 인증서 일련 번호와 함께 CloudTrail에 기록됩니다.
- Zero‑Trust Alignment – 짧은 수명에 자동으로 회전되는 자격 증명은 최신 보안 모범 사례에 부합합니다.
IAM Roles Anywhere 로 전환하는 것은 성숙한 AWS 아키텍처의 특징으로, 온프레미스 안정성과 클라우드 네이티브 보안 사이의 격차를 메워줍니다.