Welcome to the AWS Authentication Tool repository! This project contains a .NET application designed to streamline the authentication process for AWS services like CodeArtifact and ECR. This tool helps you log into each service and update necessary tokens or credentials, with detailed logging for easy auditing and troubleshooting. This version is a more robust and versatile alternative to the PowerShell scripts previously provided.
- Authenticate and log into AWS CodeArtifact repositories.
- Authenticate Docker with AWS ECR.
- Cross-platform compatibility (Windows, macOS, and Linux).
- Built with .NET 8 for improved performance and reliability.
- Detailed logging with Serilog.
- .NET 8 SDK installed. Download it from the .NET website.
- AWS CLI installed and configured. For more information, refer to the AWS CLI Installation Guide and Configuring the AWS CLI.
- Docker installed (for ECR authentication).
- Access to the AWS CodeArtifact and ECR services.
- Proper configuration of AWS credentials and region.
-
Download the latest release from the Releases page.
-
Extract the release package to your desired location.
Run the tool with the desired command and options:
dotnet AwsServiceAuthenticator.Cli.dll --command nuget --region us-east-1 --logFolderPath ./logs
nuget
: Refreshes authentication tokens for AWS CodeArtifact.ecr
: Refreshes authentication tokens for AWS ECR.--command
: The command to execute (nuget
orecr
).--region
: The AWS region to use (e.g.,us-east-1
).--logFolderPath
: The path to the log file.
To ensure that your development machine is always authenticated with the necessary services, you can add this tool to your cron jobs (Linux/macOS) or Task Scheduler (Windows). This way, you can automate the authentication process to run at startup or at regular intervals.
-
Open your crontab configuration:
crontab -e
-
Add the following line to run the tool at startup (adjust the path as needed):
@reboot dotnet /path/to/AwsServiceAuthenticator.Cli.dll --command nuget --region us-east-1 --logPath /path/to/logs @reboot dotnet /path/to/AwsServiceAuthenticator.Cli.dll --command ecr --region us-east-1 --logPath /path/to/logs
-
Open Task Scheduler and create a new task.
-
Set the trigger to run the task at login.
-
Set the action to start a program and use the following settings:
dotnet C:\path\to\AwsServiceAuthenticator.Cli.dll --command nuget --region us-east-1 --logPath C:\path\to\logs
-
Repeat for the other command if needed.
The tool uses configuration variables that can be modified as needed:
- REGION: The AWS region where the service is hosted. Default is
us-east-1
. - LOG PATH: The path to the log file.
You can set these variables through the command line options as shown in the usage section.
- .NET 8 SDK installed. Download it from the .NET website.
- AWS CLI installed and configured.
- Docker installed (for ECR authentication).
- Proper configuration of AWS credentials and region.
-
Clone the repository:
git clone https://github.com/karimz1/AWS-Service-Authentication-Tool.git cd AWS-Service-Authentication-Tool
-
Build the project:
dotnet build --configuration Release
Run the tool with the desired command and options:
dotnet run --project ./src/AwsServiceAuthenticator.Cli/AwsServiceAuthenticator.Cli.csproj -- --command nuget --region us-east-1 --logPath ./logs
To run the tests, use the following command:
dotnet test
This repository is set up to use GitHub Actions for continuous integration and deployment. The workflow builds and releases the project for Windows, macOS, and Linux.
The GitHub Actions workflow is defined in .github/workflows/release.yml
.
The workflow is triggered on push to tags matching the pattern v*.*.*
(e.g., v1.0.0
).
- Build: Builds the project for Windows, macOS, and Linux.
- Create Release: Creates a GitHub release and uploads the built artifacts.
To create a new release, push a tag to the repository:
git tag v1.0.0
git push origin v1.0.0
This will trigger the GitHub Actions workflow, which will build the project for all specified platforms and create a release with the built artifacts.
For users who prefer PowerShell, there is a PowerShell version of these scripts available here. This version requires PowerShell Core and provides similar functionality for AWS authentication.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are very welcome! If you have suggestions, improvements, or bug fixes, please open an issue or submit a pull request. Let's make this project even better together!