Q:

Bash aliasing not replacing as expected

I am trying to alias the name of an S3 bucket to save having to enter it constantly when transferring files.
In my .bash_profile:
alias as3="aws s3"
alias artifacts="s3://dev-artifacts-bucket-name"
alias admin="--profile admin-user"

Example desired command using aliases:
as3 cp localFile.txt artifacts/ admin

Which should resolve to:
aws s3 cp localFIle.txt s3://dev-artifacts-bucket-name/ --profile admin-user

Where "admin-user" is the name of an IAM role configured in my ~/.aws/config file.
Instead I get the error:
as3 cp ./upload.sh artifacts/ admin

Unknown options: admin

or when I eliminate the profile alias
as3 cp ./upload.sh artifacts/ --profile admin-user

usage: aws s3 cp <LocalPath> <S3Uri> or <S3Uri> <LocalPath> or <S3Uri> <S3Uri>
Error: Invalid argument type

The error message clearly shows the first alias working since I get the "aws s3" usage error, but the second alias does not get triggered. Tried debugging with set -x and got:
as3 cp upload.sh artifacts admin
+ aws s3 cp upload.sh artifacts admin

Unless bash detects recursive alias substitution and stops it with an obtuse error, I'm at a loss for what is happened.
FYI: I'm a self declared bash noob, be gentle.
(yes, I sourced the .bash_profile)

A:

You are confusing alias in Bash with variables. An alias can only be used as the start of a command.
The arguments can instead be variables:
alias as3="aws s3"
artifacts="s3://dev-artifacts-bucket-name"
admin="--profile admin-user"

Then you can:
as3 cp localFile.txt $artifacts/ $admin

