Skip to content
Eric Odell edited this page Jun 8, 2020 · 7 revisions

cloud9

Howto assume roles for cross account access

Install latest aws-vault binary for your system, eg for linux

sudo curl -L -o /usr/local/bin/aws-vault https://github.com/99designs/aws-vault/releases/download/v5.4.4/aws-vault-linux-amd64
sudo chmod 755 /usr/local/bin/aws-vault

Add the following to your ~/.bashrc:

echo 'export AWS_VAULT_BACKEND="file"' >> ~/.bashrc
source ~/.bashrc

Add access keys

aws-vault add my-profile

Then add to ~/.aws/config the profiles you need to assume:

[profile my-new-profile] mfa_serial=arn:aws:iam::111111111111:mfa/myuser parent_profile=ucop role_arn=arn:aws:iam::2222222222222:role/path/my-role source_profile=my-profile

Howto embiggen c9 instance

# Get the ID of the envrionment host Amazon EC2 instance.

INSTANCEID=$(curl http://169.254.169.254/latest/meta-data//instance-id)

# Get the ID of the Amazon EBS volume associated with the instance.

VOLUMEID=$(aws ec2 describe-instances --instance-id $INSTANCEID | jq -r .Reservations[0].Instances[0].BlockDeviceMappings[0].Ebs.VolumeId)

# grow volume by how ever much you need, here's an example of changing to 40 GB

aws ec2 modify-volume --volume-id  $VOLUMEID --size 40
aws ec2 describe-volumes --volume-ids $VOLUMEID

# figure out which disk you want to embiggen, here's an example using ubuntu c9 instance

sudo growpart /dev/nvme0n1 1
sudo resize2fs /dev/nvme0n1p1

How to simulate codebuild

You can reverse engineer buildspec.yaml if you want to manually run things like "cdk synth", "cdk diff", "cdk deploy", etc. But wouldn't you rather just run codebuild locally to test your infrastructure as code? Here's how:

  • clone code to build local codebuild docker image in ~/environment
mkdir -p ~/github/aws/ /tmp/artifacts
git clone https://github.com/aws/aws-codebuild-docker-images.git ~/github/aws/aws-codebuild-docker-images
  • build local docker image to run codebuild, this will take some time and take ~10GB disk space. see hints down below for how to embiggen a c9 instance for more disk space.
cd ~/github/aws/aws-codebuild-docker-images/ubuntu/standard/4.0/
docker build -t aws/codebuild/standard:4.0 .
  • set region so docker runtime will inherit with -c
export AWS_REGION="us-west-2"
  • run codebuild locally
~/github/aws/aws-codebuild-docker-images/local_builds/codebuild_build.sh -i aws/codebuild/standard:4.0 -a /tmp/artifacts -s ~/your/app/repo/with/buildspec/at/root -c

Boom!

Clone this wiki locally