Skip to content

Commit

Permalink
feat: bash script addon
Browse files Browse the repository at this point in the history
  • Loading branch information
RamaRaju-vj committed Jul 2, 2024
1 parent abea698 commit 1dd0973
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 36 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/jenkins-ami.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,20 @@ jobs:
run: |
sed -i "s|ADMIN_USER|${{ secrets.JENKINS_ADMIN_USER }}|g" jenkins/jenkins.yaml
sed -i "s|ADMIN_PASSWORD|${{ secrets.JENKINS_ADMIN_PASSWORD }}|g" jenkins/jenkins.yaml
sed -i "s|docker_hub_username|${{ secrets.docker_hub_username }}|g" jenkins/jenkins.yaml
sed -i "s|docker_hub_password|${{ secrets.docker_hub_password }}|g" jenkins/jenkins.yaml
sed -i "s|jenkins_ami_git_url|${{ secrets.GIT_JENKINS_AMI_REPO_URL }}|g" jenkins/build-docker-image.groovy
sed -i "s|git_username|${{ secrets.git_username }}|g" jenkins/jenkins.yaml
sed -i "s|GITHUB_TOKEN|${{ secrets.GIT_TOKEN }}|g" jenkins/jenkins.yaml
sed -i "s|\${AWS_ACCESS_KEY_ID}|${{ secrets.AWS_ACCESS_KEY_ID }}|g" jenkins/jenkins.yaml
sed -i "s|\${AWS_SECRET_ACCESS_KEY}|${{ secrets.AWS_SECRET_ACCESS_KEY }}|g" jenkins/jenkins.yaml
sed -i "s|\${AWS_ACCESS_KEY_ID}|${{ secrets.AWS_ACCESS_KEY_ID }}|g" scripts/install.sh
sed -i "s|\${AWS_SECRET_ACCESS_KEY}|${{ secrets.AWS_SECRET_ACCESS_KEY }}|g" scripts/install.sh
sed -i "s|\$AWS_ACCESS_KEY_ID|${{ secrets.AWS_ACCESS_KEY_ID }}|g" scripts/install.sh
sed -i "s|\$AWS_SECRET_ACCESS_KEY|${{ secrets.AWS_SECRET_ACCESS_KEY }}|g" scripts/install.sh
sed -i "s|\$AWS_REGION|${{ secrets.AWS_REGION }}|g" scripts/install.sh
shell: bash

- name: Build AMI
Expand Down
38 changes: 4 additions & 34 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,40 +167,10 @@ unzip awscliv2.zip
sudo ./aws/install
sudo aws --version


# Clear any existing AWS configuration
sudo rm -rf ~/.aws
sudo mkdir -p ~/.aws

# Create AWS credentials file
cat <<EOL > ~/.aws/credentials
[default]
aws_access_key_id = ${AWS_ACCESS_KEY_ID}
aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}
EOL

# Create AWS config file
cat <<EOL > ~/.aws/config
[default]
region = us-east-1
EOL

# Verify AWS CLI configuration
echo "Verifying AWS CLI configuration..."
cat ~/.aws/credentials
cat ~/.aws/config

# Verify AWS CLI can authenticate
echo "Verifying AWS CLI authentication..."
aws sts get-caller-identity

if [ $? -eq 0 ]; then
echo "AWS CLI is configured correctly and can authenticate."
else
echo "Failed to authenticate with AWS CLI."
exit 1
fi

# Configure AWS CLI
aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID"
aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY"
aws configure set default.region "$AWS_REGION"


# Install kubectl and AWS IAM Authenticator
Expand Down

0 comments on commit 1dd0973

Please sign in to comment.