Changing AWS configuration directory - amazon-web-services

AWS stores the default configuration files in ~/.aws/.
I'm trying to have all hidden directories inside ~/.config/, and would like to change the default location to ~/.config/aws/
How would I do this from the AWS CLI?

You can specify a non-default location for the config file by setting the AWS_CONFIG_FILE environment variable to another local path.
Steps I used:
1. Create a folder with the name of your choice. I used .awscheck (mkdir .awscheck)
2. Create a file named credentials within the folder.
3. Configure the variable. (export AWS_CONFIG_FILE=~/.awscheck/credentials)
4. Run aws configure and add your values.
Similarly, if you want to store configurations, you can create a config file and add the configurations like profiles and regions in the config file.

Custom locations for config and credentials files can be specified using two environment variables:
AWS_CONFIG_FILE: Specifies the location of the file that the AWS CLI uses to store configuration profiles. The default path is ~/.aws/config.
AWS_SHARED_CREDENTIALS_FILE: Specifies the location of the file that the AWS CLI uses to store access keys. The default path is ~/.aws/credentials.

Related

CodePipeline - CodeBuildStage with overridden artifact upload location

I have an existing CodePipeline which listens to changes to a CodeCommit repository and triggers a CodeBuild of a build project with specific environment variables and a specific artifact upload location. Is there a way to create another CodeBuild step where the same build project is run but with overridden environment variables and another artifact upload location, or will I have to create another build project with these settings?
You can set up the CodeBuild project to allow the build to override artifact names when using S3 as the artifact location. Each artifact has a OverrideArtifactName (in the console it is a checkbox called 'Enable semantic versioning') property that is a boolean. If you set this to true the buildspec will need to specify the name of the file in the artifacts section. While this field is called name, it can include the path as well. That means that you can calculate the name (including the path) based on values inside the build spec (including using environment variables).

aws configure creates userprofile folder and files

Is there a way to set the path other than %USERPROFILE% for aws configure?
I cannot explain why, but on Windows 10 after aws configure runs, it automatically creates the following path and files:
C:\Users\myusername\%USERPROFILE%\Documents.aws
Note the userprofile folder is actually named that way. It's not the windows environment folder.
Normally its supposed to create C:\users\myusername.aws etc.
No, apart from %USERPROFILE there is no other way for aws configure
aws cli configure code
def _write_out_creds_file_values(self, new_values, profile_name):
# The access_key/secret_key are now *always* written to the shared
# credentials file (~/.aws/credentials), see aws/aws-cli#847.
# post-conditions: ~/.aws/credentials will have the updated credential
# file values and new_values will have the cred vars removed.
credential_file_values = {}
Where are configuration settings stored?
Home directory is referred to using the environment variables %UserProfile% in Windows and $HOME or ~ (tilde) in Unix-based systems.
But there is something more to it:
As a general rule, any value that you can place in the credentials file can alternatively be placed in the config file. The other way isn't true: only a few settings can be placed in the credentials file.
So you can place credentials in .aws/config file,and for there is an environment variable named AWS_CONFIG_FILE you can pass and it will be written there. Even though it is not recommended to place credentials in config file

Command line interface (CLI) not working after mounting lb3 to lb4 as documented

I mounted lb3 into lb4 app as documented but now i can not use lb cli and getting the following error: "Warning: Found no data sources to attach model. There will be no data-access methods available until datasources are attached.".
It's because the cli looking for the json file in the root directory and not in the lb3app directory as advised in the upper doc.
how can i tell the CLI that the configuration files are inside the sub dir lb3app instead of the parent directory newlb4app?
tried to execute the lb from newlb4app and from the sub dir lb3app. no success.
I removed the file .yo-rc.json and it solved the problem. Seems thatthe CLI looking for that file on parents directories and if exists it set that location as the project root dir.
When i deleted the file, the parent directory is now the current directory.

How to use a custom configuration file for composer in elastic beanstalk?

How to call a custom configuration file per environment when using php's composer and amazon's elastic beanstalk?
for example, when having a "composer.dev.json" & "composer.master.json" files (one of them could request files from a "dev" version/branch and the other one for stable files).
Elastic Beanstalk has composer built-in. In order to use it, the only thing you need to do is adding a "composer.json" file in your root folder. In case you want to use a custom composer file for each version, it can also be accomplished relatively easily. Create a folder named ".elasticbeanstalk" and its relative file "optionsettings.branch-name" - it should be created using the "eb cli", particularity, with the commands "eb init" and "eb branch"- more info can be found here http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cmd-commands.html.
After we have the optionsettings file, we should define a param named "COMPOSER" in there and just have it to point to the custom composer file we would like to run, for example:
[aws:elasticbeanstalk:application:environment]
COMPOSER=composer.dev.json
on your next deploment, it should run the composer using composer.dev.json

How to set environment variable for root user at start-up?

I'm trying to add memory usage monitoring to the monitoring tab of an instance at console.aws.amazon.com. It's an instance running Amazon Linux AMI 2013.09.2 I have found the Amazon CloudWatch Monitoring Scripts for Linux and specifically mon-put-instance-data.pl that let's me collect memory stats and report it to CloudWatch as custom metrics.
To have this working I need to set the environment variable AWS_CREDENTIAL_FILE to point to a file containing my AWSAccessKeyId and AWSSecretKey. I do this by typing:
export AWS_CREDENTIAL_FILE=/home/ec2-user/aws-scripts-mon/awscreds.template
To avoid having to type this over and over again, I'm looking for a way to set the environment variable at startup. I have tried adding the code to these files:
/etc/rc.local file
/etc/profile
/home/ec2-user/.bash_profile
As adding the line of code in either of the files seems to work when I switch to root user, where should I put it? If I set the variable in /home/ec2-user/.bash_profile the variable is set for ec2-user but not for root. If i then sudo -E su it works, but I don't know if this is the best way to go about it?
Create a sh file and put the code in it. Then put this sh file in /etc/profile.d/ folder.
Note: create this sh file using the root user.
Once your instance is created, this sh file will automatically run and creates the environment variable for you and this environment variable will be accessible to all the users.