Wondering how to provision S3 bucket using Pulumi? Our in-house experts are here to help you out with this article. Our AWS support is here to offer a lending hand with your queries and issues.
How to provision S3 bucket using Pulumi?
Pulumi is an infrastructure as a code tool that enables IT administrator to write infra maps in higher level programming language such as Javascript . Go , Python etc.
The tool can integrate into a CI/CD platform using the CLI which talks to the pulumi engine.
Problem that Pulumi solves
Well now devops is all about automation.
The human being is totally relied upon automation which adds an extra layer of dependency.The tool gives few benefits such as
- Firstly Pulumi , integrated with CI and CD directly. Secondly there is no need for CLI to perform changes.
- Moreover the delivery with Pulumi is really fast as it is independent of other tools.
In this paragraph Pulumi follows the yaml which we can use to configure system.Today we will discover as how this pulumi can be used to create a s3 bucket .
For this we will use the yaml for configuring and automating.
Today, let us see the steps followed by support techs to provision s3 bucket
Step1: Installing Pulumi
Firstly, we will install Pulumi . To install it follow the below steps.
Then, run the below command in your terminal.
curl -fsSL https://get.pulumi.com | sh
Next to access and work with pulumi we need an account on that. To make an account we will move on the next steps.
Step2: Creation of account in pulumi
After installing the binary , the next step is to create an account. After that we will create an access token in the project .
Prerequisites
- A user should have a github or gitlab account.
To create the account follow the below link :-
Link for account – https://app.pulumi.com/signin\
To create the account click on the above link
On the above page click on the above mentioned type as per your requisite.Ill be doing it with github.
Step3: Generation of Personal access token
To generate the token login and move towards the setting -> Access token . The output below shows the access token page .
To generate the token click on create token and it would ask for a name .Generate the token and next will create a pulumi project.
Step4: Pulumi project creation
To create the project first we need to export few environment variables .The environment variable will contain the aws keys etc and access token of pulumi.
export AWS_ACCESS_KEY_ID= xxxxxxxxxxxxxxxxxxxxxx
export AWS_SECRET_ACCESS_KEY= xxxxxxxxxxxxxxxxxxx
export PULUMI_ACCESS_TOKEN= xxxxxxxxxxxxxxxxxxxxxx
export AWS_REGION= ap-south-1
export PULUMI_EXPERIMENTAL= true
NOTE – The Pulumi experimental is true that is required to enable additional features like plan and apply .
So for the configuration it needs yaml . For that we need to install yaml plugin. In this most of the explicit resources needs to be installed as a plugin. To install these plugin there is a simple command mentioned below.
pulumi plugin install language yaml
Like the above to install any resource just run the below command:-
pulumi plugin install resource aws
The above shows the installation output of the resource and language.
Initializing the project now
To initialize the project and stack we need to do the following.But before initializing lets know what stack is.
A stack is an isolated, independently configurable instance of a Pulumi program.
To initialize lets run the below command in our terninal.
pulumi new aws-yaml
The above command will initialize a new project and the output will be like below.
Next command is to select the dev stack.
The below command will help to select the dev stack .Next this will help to up the project as per the infrastructure.
Provisioning Infrastructure – Setting up s3 using the yaml.
After initializing the project and stack , lets move towards the set up of Infra as code using the above tool. To do this we will use the config as yaml. The config file is used to set up the s3 bucket.The below file is a simple yaml configuration. It will have the resource section , bucket name as per now.
A file is generated in the above command while initializing the project.
The below code snippet represents the content of the file.
name: demo1
runtime: yaml
description: a demo project
resources:
# Create an AWS resource (S3 Bucket)
my-bucket:
type: aws:s3:Bucket
outputs:
# Export the name of the bucket
bucketName: ${my-bucket.id}
Next to verify the plan run the below command.It will tell about the components that will be up in the infra. This step will be used to preview the planned state .
pulumi preview --save-plan plan.json
Once the above changes is fine , proceed with the infra provisioning. Next we will run the below command to provision the infra.
pulumi up --plan='plan.json' --non-interactive --yes
As the above output shows the creation of s3 using the above IAC.
Lastly the above bucket is made by the infra provisioning of yaml configuration in YAML.
How to access log
To access logs you should use the below command.
pulumi logs -f
Destroy the resources
pulumi destroy -y
[Looking for a solution to another query? We’re happy to help.]
Conclusion
In this article, we provide a quick and simple solution from our Support team to how to provision S3 bucket using Pulumi
0 Comments