Attini quick start¶
Attini is free to use, however the underlying serverless AWS resources could generate a small cost if you exceed the AWS free tier.
In this guide we will:
Create a
hello-word
Attini projectCreate an Attini distribution from the project
Deploy the Attini distribution to
stage
Deploy the Attini distribution to
production
Before you start, you need an AWS Account and the AWS CLI (with configured credentials). Attini uses your existing AWS credentials so you have to be logged in.
Note
The Attini Framework will get configuration appropriate for a Sandbox environment. To do a proper installation, please see installing the Attini CLI and Install the Attini Framework.
Get started¶
Verify your AWS Credentials
aws sts get-caller-identity
Create a working directory
mkdir -p attini-hello-world
cd attini-hello-world
The next step is to install the Attini CLI and the Attini Framework
Install the Attini CLI¶
The Attini CLI is available for macOS and Linux. For Windows users, we recommend WSL or a virtual machine.
Download the CLI
/bin/bash -c "$(curl -fsSL https://docs.attini.io/blob/attini-cli/install-cli.sh)"
Click here for more information about the Attini CLI installation.
See the CLI options with the help command
attini --help
Or go to our CLI API documentation.
Onboard the Attini Framework¶
This step takes about 4 min.
attini setup --accept-license-agreement --create-deployment-plan-default-role --create-init-deploy-default-role
Note
If you get the error Text {date} could not be parsed at index 19
please see our common issues.
For more information about the options, please see Install the Attini Framework.
Initiate and deploy a project¶
The hello-world
project (when deployed) will create an AWS SSM Parameter,
a Lambda function that reads the Parameter, and an API Gateway that triggers the Lambda. The SSM parameter
will contain different values depending on what environment the project is deployed to. This is because of how
the attini-config.yaml
is configured.
Solution architecture
Deploy process
Initiate a hello-world project
attini init-project hello-world
Create a distribution from the project
attini distribution package .
Find more information about attini distribution package here.
Register the stage environment with Attini
attini environment create stage --env-type test
This command tells Attini that it’s ok to deploy to stage
in this AWS Account and Region.
The --env-type test
flag tells Attini that this is a test environment so we will not prompt for deployment conformations.
Find more information about Attini environments here.
Deploy your Attini distribution to stage
attini deploy run attini_dist/hello-world.zip -e stage
Attini will now run the init deployment and execute the deployment plan.
Test the endpoint
STAGE_ENDPOINT=$(aws cloudformation describe-stacks --stack-name stage-hello-world-lambda --query 'Stacks[0].Outputs[?OutputKey==`Endpoint`].OutputValue' --output text)
echo $STAGE_ENDPOINT
curl $STAGE_ENDPOINT
This script reads the CloudFormation output from our ${environment}-hello-world-lambda
stack which contains our API Gateways endpoint.
Then it prints the endpoint (URL) and calls it using curl
.
Deploy to production
Now we want to create a new environment (in this example we create a production
environment) and deploy the same distribution to it.
So we will run the same commands as we did above, but with the environment name production
:
attini environment create production
attini deploy run attini_dist/hello-world.zip -e production
Test the endpoint
PRODUCTION_ENDPOINT=$(aws cloudformation describe-stacks --stack-name production-hello-world-lambda --query 'Stacks[0].Outputs[?OutputKey==`Endpoint`].OutputValue' --output text)
echo $PRODUCTION_ENDPOINT
curl $PRODUCTION_ENDPOINT
Check your deployments
Now that we deployed the same distribution to two different environments we can use the context
command to get an overview of our different environments:
attini environment context
The output should look something like this:
attiniVersion: "X.X.X"
account: "111111111111"
user: "arn:aws:sts::111111111111:assumed-role/role-name/xxxxxxxx"
region: "eu-west-1"
environments:
- environmentName: "prod"
distributions:
- name: "hello-world"
distributionId: "YYYY-MM-DD_HH:MM:SS"
deploymentPlans:
- name: "AttiniDeploymentPlanSfnHelloWorldDeploymentPlan-xxxxxxxxxxxx"
lastStatus: "SUCCEEDED"
lastExecutionStart: "2022-01-01 01:01:01"
- environmentName: "stage"
distributions:
- name: "hello-world"
distributionId: "YYYY-MM-DD_HH:MM:SS"
deploymentPlans:
- name: "AttiniDeploymentPlanSfnHelloWorldDeploymentPlan-xxxxxxxxxxxx"
lastStatus: "SUCCEEDED"
lastExecutionStart: "2022-01-01 01:05:01"
You can easily see:
What environments you have in this AWS Account and Region.
What distributions you have in every environment.
The distribution id tells us if the environments are on the same version.
Conclusion and next steps¶
We have created a straightforward hello-world example using Attini and deployed it to two different environments.
It was then very easy to compare the configuration of our environments using the
attini environment context
command.To do this, Attini only used your AWS credentials, and the deployment was done using serverless resources inside of your AWS Account, removing any dependency on a central CI/CD tool.
Your current CI/CD tools are easily extended with Attini, you just have to install the Attini CLI on your worker nodes.
The Attini way of working provides many advantages, so please keep on experimenting!
If you need any support or have feedback, please send us an email at
support@attini.io
.
Clean up¶
Below is a script that will delete everything from the guide above. If you have added your own stacks or deployed to other environments, please adjust the script accordantly.
attini environment remove stage
attini environment remove production
aws cloudformation delete-stack --stack-name stage-hello-world-lambda
aws cloudformation delete-stack --stack-name stage-hello-world-parameter
aws cloudformation delete-stack --stack-name stage-hello-world-deployment-plan
aws cloudformation delete-stack --stack-name production-hello-world-lambda
aws cloudformation delete-stack --stack-name production-hello-world-parameter
aws cloudformation delete-stack --stack-name production-hello-world-deployment-plan
aws ssm delete-parameters --names /attini/distributions/stage/hello-world/latest /attini/distributions/production/hello-world/latest
To remove the Attini Framework please see Deleting/Clean up the Attini Framework.
To uninstall the Attini CLI please see Uninstall the Attini CLI.