Does anyone here have any experience of (starting from scratch or with no AWS resources) setting up policies/users/resources/configurations via something similar to the Deployment Managers of GCP and Azure?.. preferably something declarative or via templates?
Bash-my-AWS looks like a great step towards the goal I have in mind but I may also just be unaware of other tooling or AWS capabilities.
It is unwise IMHO to use CloudFormation currently unless you're provisioning resources so obscure they didn't yet make it to tf aws provider.
BTW your Dockerfile pretty much boils down to:
FROM alpine:3.10
RUN apk add --no-cache \
python3
RUN pip3 install awscli
COPY config /root/.aws/
COPY credentials /root/.aws/Isn't there precedent for terraform getting support for things before cloudformation?
While I think the HCL DSL was a mistake and prefer the CloudFormation YAML, CloudFormation has its share of warts as well, and the TF community has been doing better than CF in staying up-to-date with the AWS API updates - which reflects quite poorly on AWS actually.
> would not recommend to use terraform at all since you will run into warts and fundamental issues
It's not a good look to be employed by the 800 pound gorilla and bash your company's competitor without mentioning specifics.
I am in no way affiliated with them other than being a customer
I just finished a POC that generates 90% of the AWS services I use per client/project/application. The remaining 10% is DNS stuff that I can easily do by hand, but with a few clicks I get everything provisioned with much less human error (buckets, Lambdas, API Gateways, Cloudfront distributions, etc.)
The formation definition is ~1000 lines of JSON, but it explicitly describes everything I need and it takes in parameters - it's wonderful! Thank you again!
You might consider using Terraform directly if you want something more mature.
Meta note: All things considered, Amazon has it pretty good. They put out a barely usable, bare-bones, but fully functional tool in awscli. Paying customers of AWS have to perform the engineering effort to make the API more usable, and some even open-source their projects like this. AWS is an incredible business model.
My reasons for continuing include:
- I prefer to use command line over ClickOps
- Using Bash-My-AWS makes me more effective at work
- The emergent UX is equally applicable to other services (e.g. bash-my-github, bash-my-spotify)
- The intrinsic satisfaction from creating
- Helping improve the experience for others
I love that a community has an option to build components and share the same. It has made my work much more productive.
But we certainly agree on that last point: it’s an incredible business model.
AWS CLI v2 previews were released in Nov 19 and while this may contain some breaking changes, I wouldn't be surprised if all the commands BMA uses continue to work as normal.
https://aws.amazon.com/blogs/developer/aws-cli-v2-installers...
Not to take anything away from the author of this project - Bash-my-aws looks fantastic - but it only helps you with a few core services. Same appears to be true of the commandeer tool that has also been mentioned in this thread. And the same is true for localstack, and on and on.
I really wish AWS would devote some resources to filling in these gaps themselves, and comprehensively.
The listing functions output lines of tokens. The first token is the resource identifier. Piping that output into functions for that resource type results in the resource IDs only being used.
$ instances
i-03dfa28fc8235df7b t3.nano running prometheus 2019-12-31T14:10:45.000Z ap-southeast-2a vpc-9def06f8
i-0fd7a4c81051f2718 t3.nano running huginn 2019-12-31T14:10:44.000Z ap-southeast-2a vpc-9def06f8
i-0abcd6e9c302f35bb t3.nano running rails-demo 2019-12-31T14:10:47.000Z ap-southeast-2b vpc-9def06f8
$ instances | grep rails-demo | instance-asg | asg-capacity
rails-demo-AutoScalingGroup-14SBR6O3W1FBL 0 1 2
$ instances | grep rails-demo | instance-asg | asg-
asg-capacity asg-launch-configuration asg-processes_suspended asg-stack
asg-desired-size-set asg-max-size-set asg-resume asg-suspend
asg-instances asg-min-size-set asg-scaling-activities
$ instances | grep rails-demo | instance-asg | asg-desired-size-set 2
$ instances | grep rails-demo | instance-asg | asg-capacity
rails-demo-AutoScalingGroup-14SBR6O3W1FBL 0 2 2The problem I run into is that it just feels like so much typing to me. I have to read documentation. All the attributes HaveReallyLongNamesThatContainCapitalLetters. By the time I've made my beta version of the command I want to run, I feel like I need to open a text editor to finish it. Maybe add some error checking. Some comments too. Maybe a unit test or three. And now I have an entire project and all I wanted to do was add a line of text to the end of a file.
Part of the problem on my part is my own ignorance of the APIs and what commands are available to me. But it all seems too verbose to use practically. The Powershell language seems very good for what you would write a shell script to do, but for interactive commands, I have a hard time believing that people use it. It's just so verbose.
The result is you have a simple set of commands that don't require you to type hundreds of characters.
instances() {
local instance_ids=$(__bma_read_inputs)
local filters=$(__bma_read_filters $@)
aws ec2 describe-instances \
$([[ -n ${instance_ids} ]] && echo --instance-ids ${instance_ids}) \
--query "
Reservations[].Instances[][
InstanceId,
InstanceType,
State.Name,
[Tags[?Key=='Name'].Value][0][0],
LaunchTime,
Placement.AvailabilityZone,
VpcId
]" \
--output text |
grep -E -- "$filters" |
LC_ALL=C sort -b -k 6 |
column -s$'\t' -t
}If anyone can help with a solution I'd be delighted to remove the dependency on jq.
https://github.com/bash-my-aws/bash-my-aws/blob/b74d92a902bb...
https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-o...
"For more advanced filtering that you might not be able to do with --query, you can consider jq, a command line JSON processor. You can download it and find the official tutorial at http://stedolan.github.io/jq/."
Bash-My-AWS is a simple but extremely powerful set of CLI commands for managing resources on Amazon Web Services. They harness the power of Amazon's AWSCLI, while abstracting away the verbosity. The project implements some innovative patterns but (arguably) remains simple, beautiful, readable and easily extensible.
The project started in 2014 and while many hundreds of hours have gone into it, far less has gone into promotion.
I'm speaking about it at LinuxConf and have created a documentation site at https://bash-my-aws.org
I wish people would stop making websites that's require JS.
One thing I've not been able to work out with bash-my-aws yet was how to easily switch between regions and accounts. I noticed you can use `region` on it's own to set the current default region, but I'm often working with multiple regions, and it'd be a pain to have to run `region us-west-1` separately each time I want to use a different region. I couldn't see a way to just specify a region for a given command (eg how you'd do `aws get-instances --region us-west-1`). I guess you could do this with the environment variable `AWS_DEFAULT_REGION=us-west-1 instances` but that's a bit verbose.
Similarly with AWS accounts, I use multiple AWS accounts, which are accessed with different access keys, which are defined as profiles in my ~/.aws/config. Normally I'd use these with the AWS CLI like `aws ec2 get-instances --profile production`, I couldn't see any way in the docs to use or set this?
The AWCLI, as well as SDKs all support grabbing Regions and account credentials from environment variables.
For Regions, I work tend to use the following aliases:
alias au='export AWS_DEFAULT_REGION=ap-southeast-2'
alias us='export AWS_DEFAULT_REGION=us-east-1'
alias dr='export AWS_DEFAULT_REGION=ap-southeast-1'
I normally work in a single Region and swap when required by typing the 2 character alias.To run a script or command (doesn't have to be Bash-my-AWS) across all Regions I use region-each:
$ region-each stacks | column -t
example-ec2-ap-northeast-1 CREATE_COMPLETE 2011-05-23T15:47:44Z NEVER_UPDATED NOT_NESTED #ap-northeast-1
example-ec2-ap-northeast-2 CREATE_COMPLETE 2011-05-23T15:47:44Z NEVER_UPDATED NOT_NESTED #ap-northeast-2
...
example-ec2-us-west-2 CREATE_COMPLETE 2011-05-23T15:47:44Z NEVER_UPDATED NOT_NESTED #us-west-2
For AWS accounts, I type the name of the account and I'm in. For accounts using IDP (ldap/AD backed corporate logins) I generate aliases so I have tab completion and simple naming.In accounts that are only setup to use AWS keys, I use aliases that export credentials kept in GPG encrypted files. Last time I looked, AWS docs suggested keeping these long lives credentials in plaintext files readable by your account. That's asking for trouble IMO, especially if they're kept in a known location that a compromised node library could exfiltrate them from.
AWSCLI v2 beta includes support for SSO so it's probably a good time to look at how BMA could include support for auth.
Bash-My-AWS thinly wraps AWSCLI commands that would otherwise be too long to type. So you're still using AWSCLI and can improve your skill with it by inspecting the source of Bash-My-AWS functions.
You can just type bma[TAB][TAB] and it will list them all.
If you know the type of resource you are working with, you can use TAB completion to see it's commands:
$ stack-
stack-arn stack-exports stack-tag-apply
stack-asg-instances stack-failure stack-tag-delete
stack-asgs stack-instances stack-tags
stack-cancel-update stack-outputs stack-tags-text
stack-create stack-parameters stack-tail
stack-delete stack-recreate stack-template
stack-diff stack-resources stack-update
stack-elbs stack-status stack-validate
stack-events stack-tagThe intent has always been to enhance rather than replace AWCLI (which is an amazing tool!).
If you're ever wondering how a Bash-My-AWS command works, use `bma type` (it even supports tab completion for all the commands).
$ bma type instances
instances is a function
instances ()
{
local instance_ids=$(__bma_read_inputs);
local filters=$(__bma_read_filters $@);
aws ec2 describe-instances $([[ -n ${instance_ids} ]] && echo --instance-ids ${instance_ids}) --query "
Reservations[].Instances[][
InstanceId,
InstanceType,
State.Name,
[Tags[?Key=='Name'].Value][0][0],
LaunchTime,
Placement.AvailabilityZone,
VpcId
]" --output text | grep -E -- "$filters" | LC_ALL=C sort -b -k 6 | column -s' ' -t
}Google cloud CLI offers all of this out of the box. Why Amazon wants to make such basic commands difficult, I'll never understand.