Created
November 18, 2021 14:20
-
-
Save vfarcic/4f0d8213d47e7c176e7d7f401adfa19e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######### | |
# Setup # | |
######### | |
# https://github.com/localstack/localstack/blob/master/doc/feature_coverage.md | |
git clone https://github.com/vfarcic/localstack-demo | |
cd localstack-demo | |
# Replace `[...]` with the API key | |
export LOCALSTACK_API_KEY=[...] | |
cat orig/values.yaml \ | |
| sed -e "s@value: API_KEY@value: $LOCALSTACK_API_KEY@g" \ | |
| tee values.yaml | |
# It can be run in Docker (including Compose), in a Kubernetes cluster, or directly through the CLI | |
# pip install localstack | |
helm repo add localstack \ | |
https://helm.localstack.cloud | |
helm repo update | |
cat values.yaml | |
helm upgrade --install \ | |
localstack localstack/localstack \ | |
--namespace localstack \ | |
--create-namespace \ | |
--values values.yaml | |
# Run the commands from the Helm output | |
# If using a local Kubernetes cluster like, for example, Rancher Desktop, the `NODE_IP` should be `127.0.0.1` | |
# Replace `[...]` from the output | |
export LOCALSTACK_URL=[...] | |
export AWS_ACCESS_KEY_ID=test | |
export AWS_SECRET_ACCESS_KEY=test | |
export AWS_DEFAULT_REGION=us-east-1 | |
echo "[default] | |
aws_access_key_id = $AWS_ACCESS_KEY_ID | |
aws_secret_access_key = $AWS_SECRET_ACCESS_KEY | |
" >aws-creds.conf | |
kubectl create namespace crossplane-system | |
kubectl --namespace crossplane-system \ | |
create secret generic aws-creds \ | |
--from-file creds=./aws-creds.conf | |
helm repo add crossplane-stable \ | |
https://charts.crossplane.io/stable | |
helm repo update | |
helm upgrade --install \ | |
crossplane crossplane-stable/crossplane \ | |
--namespace crossplane-system \ | |
--create-namespace \ | |
--wait | |
################################################ | |
# Setup LocalStack And Crossplane AWS Provider # | |
################################################ | |
# Both LocalStack and Crossplane are already running | |
cat crossplane-config/provider-aws.yaml | |
kubectl apply \ | |
--filename crossplane-config/provider-aws.yaml | |
kubectl apply \ | |
--filename crossplane-config/provider-config-aws.yaml | |
# Please re-run the previous command if the output is `unable to recognize ...` | |
######################### | |
# S3 LocalStack Example # | |
######################### | |
cat examples/aws-bucket.yaml | |
kubectl apply \ | |
--filename examples/aws-bucket.yaml | |
kubectl get buckets | |
alias aws="aws \ | |
--endpoint-url $LOCALSTACK_URL" | |
aws s3api list-buckets | |
aws s3api put-object \ | |
--bucket a-team-bucket \ | |
--key silly \ | |
--body silly.txt | |
aws s3api list-objects \ | |
--bucket a-team-bucket | |
aws s3api delete-object \ | |
--bucket a-team-bucket \ | |
--key silly | |
kubectl delete \ | |
--filename examples/aws-bucket.yaml | |
kubectl get buckets | |
aws s3api list-buckets | |
########################## | |
# RDS LocalStack Example # | |
########################## | |
cat examples/aws-rds.yaml | |
kubectl apply \ | |
--filename examples/aws-rds.yaml | |
kubectl get rdsinstances | |
aws rds describe-db-instances | |
# Change `spec.forProvider.allocatedStorage` in `examples/aws-rds.yaml` | |
kubectl apply \ | |
--filename examples/aws-rds.yaml | |
aws rds describe-db-instances | |
kubectl delete \ | |
--filename examples/aws-rds.yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment