3.2 KiB
LocalStack Configuration
LocalStack is a local sandbox of aws environment for testing Terraform Iac and other useful things without concern about billings & payments
more information is here: https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli?in=terraform%2Faws-get-started
Requirements
first of all we need python & pip:
sudo pacman -S python
curl -sS https://bootstrap.pypa.io/get-pip.py | python
python -m pip install --upgrade pip
we need localstack python package:
pip install localstack
This installs the localstack-cli which is used to run the Docker image that hosts the LocalStack runtime.
Runing
firstly, we need localstack container invoked:
docker-compose up -d
right now we have to start localstack on host (not in container):
localstack start -d
it will get output like that:
__ _______ __ __
/ / ____ _________ _/ / ___// /_____ ______/ /__
/ / / __ \/ ___/ __ `/ /\__ \/ __/ __ `/ ___/ //_/
/ /___/ /_/ / /__/ /_/ / /___/ / /_/ /_/ / /__/ ,<
/_____/\____/\___/\__,_/_//____/\__/\__,_/\___/_/|_|
💻 LocalStack CLI 1.4.0
[20:22:20] starting LocalStack in Docker mode 🐳
preparing environment
LocalStack container named "localstack_main" is already running
at last we can check services status:
localstack status services
more information on: https://github.com/localstack/localstack
Helpful commands
use tflocal instead terraform:
pip install terraform-local
tflocal takes care of automatically configuring the local service endpoints, which allows you to easily deploy your unmodified Terraform scripts against LocalStack. Otherwise you must declare aws provider like that:
provider "aws" {
access_key = "test"
secret_key = "test"
region = "us-east-1"
s3_use_path_style = false
skip_credentials_validation = true
skip_metadata_api_check = true
skip_requesting_account_id = true
endpoints {
apigateway = "http://localhost:4566"
apigatewayv2 = "http://localhost:4566"
cloudformation = "http://localhost:4566"
cloudwatch = "http://localhost:4566"
dynamodb = "http://localhost:4566"
ec2 = "http://localhost:4566"
es = "http://localhost:4566"
elasticache = "http://localhost:4566"
firehose = "http://localhost:4566"
iam = "http://localhost:4566"
kinesis = "http://localhost:4566"
lambda = "http://localhost:4566"
rds = "http://localhost:4566"
redshift = "http://localhost:4566"
route53 = "http://localhost:4566"
s3 = "http://s3.localhost.localstack.cloud:4566"
secretsmanager = "http://localhost:4566"
ses = "http://localhost:4566"
sns = "http://localhost:4566"
sqs = "http://localhost:4566"
ssm = "http://localhost:4566"
stepfunctions = "http://localhost:4566"
sts = "http://localhost:4566"
}
}
more information on: https://docs.localstack.cloud/user-guide/integrations/terraform/