Wednesday, May 5, 2021

Create S3 Bucket in AWS using Ansible

 Description: Here I have explained, How to Create Bucket in AWS using Ansible 

Create IAM user from AWS:

  • IAM user need to Authorize Ansible Playbook to manage the S3 bucket
  • Open IAM console from AWS and navigate to IAM service 

  • Give S3 Full Access to IAM created user

  • Once the user created, download the user detail .csv file which contains Access Key and Secret ID

Install Require Ansible Packages in Ansible server
  • boto
    # pip install boto
  • boto3
    # pip install boto3
  • python version >= 2.6
    # yum install python 
Create ssh key for localhost to authorize

# ssh-keygen

  • Copy generated ssh key to authorization keys 
    # vi /root/.ssh/authorized_keys


Prepare Playbook to create S3 Bucket with Name "techblogalbucket" in "us-east-1" Region and with Public access

# vi Create_Bucket.yml --- - hosts: localhost tasks: - name: Create an S3 bucket become: true aws_s3: aws_access_key=XXXXXXXX aws_secret_key=XXXXXXXXXXXXXXX bucket=techblogalbucket mode=create permission=public-read region=us-east-1

  • Run yml file using ansible-playbook command
# ansible-playbook s3_create.yml

  • After successfully run yaml file verify S3 bucket in AWS console 


No comments:

Post a Comment