Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(devops scripts): cert cname script #17225

Closed
wants to merge 6 commits into from

Conversation

robertaandersen
Copy link
Member

@robertaandersen robertaandersen commented Dec 13, 2024

Svona lítur emailið út:

Beiðni um staðfestingu á skirteini fyrir lén

Við fengum beiðni um áframsendingu á slóð inn á undirssíðu hjá island.is. Við þurfum því að gefa út skilríki fyrir slóðina.

Bæta þarf CNAME færslum við til hægt sé að sannreyna að þau séu í nafni eiganda lénsins.

Hér koma lénin og gildin á CNAME færslunum:

  • Domain Name: rikiskaup.is

    • CNAME_VALUE: _ffa79d573e702d9a4ee6dfbd54c7f8c2.rikiskaup.is.
    • CNAME_NAME: _5bd176fc06fd003bfbf0369a1ecd5a3b.sdgjtdhdhz.acm-validations.aws.
  • Domain Name: www.rikiskaup.is

    • CNAME_VALUE: _a43297d823e90ed9744982030b572ab2.www.rikiskaup.is.
    • CNAME_NAME: _28281dbe63c8aecd4369779b05074845.sdgjtdhdhz.acm-validations.aws.
  • Domain Name: netbrot.is

    • CNAME_VALUE: _6d5c7c9e9230e1ca771cf1d81ca21710.netbrot.is.
    • CNAME_NAME: _4239527a7971b7c37b8f86c08800f911.zfyfvmchrl.acm-validations.aws.
  • Domain Name: www.netbrot.is

    • CNAME_VALUE: _d54025f88812b8b0a708ee284d0ff0aa.www.netbrot.is.
    • CNAME_NAME: _97428684905a11e25ace43eccce1c649.zfyfvmchrl.acm-validations.aws.

Með kveðju

Apró ehf.

Summary by CodeRabbit

  • New Features
    • Introduced a new script for generating a markdown file with CNAME values for certificates pending validation.
  • Documentation
    • The markdown file includes an introductory header in Icelandic explaining its purpose.

Update scripts/certs.sh

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Update scripts/certs.sh

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

Update scripts/certs.sh

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

Update scripts/certs.sh

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

fix: Reccomended fixes

fix: Reccomended fixes

fix: Reccomended fixes
@robertaandersen robertaandersen requested a review from a team as a code owner December 13, 2024 10:53
Copy link
Contributor

coderabbitai bot commented Dec 13, 2024

Warning

Rate limit exceeded

@robertaandersen has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 28 minutes and 32 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 85c4800 and 0e20152.

📒 Files selected for processing (1)
  • infra/scripts/certs.sh (1 hunks)

Walkthrough

A new Bash script named certs.sh has been added to the infra/scripts/ directory. This script generates a markdown file containing CNAME values for AWS certificates pending validation. It includes error handling, checks for AWS CLI availability, retrieves certificate information, and formats the output in Icelandic. The script ensures that the output file is created fresh, processes validation options for each certificate, and appends the results to the markdown file.

Changes

File Change Summary
infra/scripts/certs.sh Added a new script to generate a markdown file with CNAME values for certificates pending validation.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@robertaandersen robertaandersen changed the title Chore/cert cname script chore:cert cname script Dec 13, 2024
@robertaandersen robertaandersen changed the title chore:cert cname script chore: cert cname script Dec 13, 2024
@robertaandersen robertaandersen changed the title chore: cert cname script chore(devops scripts): cert cname script Dec 13, 2024
@robertaandersen
Copy link
Member Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Dec 13, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
scripts/certs.sh (2)

4-5: Consider using environment variables for configuration

For better flexibility and maintainability, consider using environment variables with defaults:

-# Configuration
-OUTPUT_FILE="${1:-email.md}"
+# Configuration
+DEFAULT_OUTPUT_FILE="email.md"
+OUTPUT_FILE="${CERT_OUTPUT_FILE:-${1:-$DEFAULT_OUTPUT_FILE}}"

18-23: Consider externalizing the message strings

The hardcoded Icelandic messages could be moved to a separate configuration file for better maintainability and potential internationalization.

+# Load messages from configuration file
+MESSAGE_FILE="${CERT_MESSAGE_FILE:-./cert-messages.conf}"
+if [ -f "$MESSAGE_FILE" ]; then
+  source "$MESSAGE_FILE"
+else
+  TITLE="# Beiðni um staðfestingu á skirteini fyrir lén"
+  INTRO="Við fengum beiðni um áframsendingu..."
+  # ... other messages
+fi
+
 {
-  printf "# Beiðni um staðfestingu á skirteini fyrir lén\n\n"
-  printf "Við fengum beiðni um áframsendingu...\n\n\n"
+  printf "%s\n\n" "$TITLE"
+  printf "%s\n\n\n" "$INTRO"
   # ... rest of the messages
 } >"$OUTPUT_FILE"
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3719969 and 09737fc.

📒 Files selected for processing (1)
  • scripts/certs.sh (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
scripts/certs.sh (1)

Pattern scripts/**/*: "Confirm that the code adheres to the following:

  • Script efficiency, readability, and maintainability.
  • Usage of environmental variables and configuration files for flexibility.
  • Integration with NX workspace utilities and commands."
🔇 Additional comments (3)
scripts/certs.sh (3)

9-16: LGTM! Good error handling for file operations

The file initialization logic is robust with proper error handling and atomic operations.


25-35: LGTM! Thorough prerequisite checks

The AWS CLI and credentials verification is well implemented with clear error messages.


1-85: Verify integration with NX workspace

As this script is part of the workspace, let's verify its integration with NX utilities and commands.

scripts/certs.sh Outdated Show resolved Hide resolved
scripts/certs.sh Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@datadog-island-is
Copy link

datadog-island-is bot commented Dec 13, 2024

Datadog Report

All test runs 7f2276f 🔗

31 Total Test Services: 0 Failed, 26 Passed
🔻 Test Sessions change in coverage: 3 decreased, 69 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 63 0 21.9s 1 no change Link
air-discount-scheme-web 0 0 0 2 0 6.45s 1 no change Link
api 0 0 0 4 0 2.44s 1 no change Link
api-domains-air-discount-scheme 0 0 0 6 0 16.59s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 10.45s 1 no change Link
application-system-api 0 0 0 46 0 2m 8.11s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 7.57s 1 decreased (-0.01%) Link
auth-admin-web 0 0 0 1 0 8.71s 1 no change Link
auth-api-lib 0 0 0 20 0 21.51s 1 no change Link
auth-shared 0 0 0 4 0 2.9s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (3)

  • services-user-profile - jest 49.25% (-0.02%) - Details
  • services-university-gateway - jest 45.23% (-0.02%) - Details
  • application-template-api-modules - jest 30.2% (-0.01%) - Details

scripts/certs.sh Outdated Show resolved Hide resolved
Copy link
Member

@brynjarorng brynjarorng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this not belong in the infra repo as the remainder of the config is there?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (3)
infra/scripts/certs.sh (3)

4-5: Add parameter validation for OUTPUT_FILE

While the default value handling is good, consider adding validation to ensure the output directory exists and is writable.

 # Configuration
 OUTPUT_FILE="${1:-email.md}"
+OUTPUT_DIR=$(dirname "$OUTPUT_FILE")
+if [ ! -d "$OUTPUT_DIR" ] || [ ! -w "$OUTPUT_DIR" ]; then
+  echo "Error: Directory $(dirname "$OUTPUT_FILE") does not exist or is not writable"
+  exit 1
+fi

25-35: Add AWS region validation

While the AWS CLI and credentials checks are good, consider adding region validation to ensure the script runs in the intended region.

 # Check AWS credentials
 aws sts get-caller-identity >/dev/null 2>&1 || {
   echo "Error: AWS credentials not configured"
   exit 1
 }
+
+# Check AWS region
+CURRENT_REGION=$(aws configure get region)
+EXPECTED_REGION="eu-west-1"  # Update this to your expected region
+if [ "$CURRENT_REGION" != "$EXPECTED_REGION" ]; then
+  echo "Error: Script must run in $EXPECTED_REGION region (current: $CURRENT_REGION)"
+  exit 1
+fi

85-85: Add error handling for final write

Consider adding error handling for the final write operation to ensure the file is properly completed.

-printf "Með kveðju\n\nApró ehf." >>"$OUTPUT_FILE"
+printf "Með kveðju\n\nApró ehf." >>"$OUTPUT_FILE" || {
+  echo "Error: Failed to write closing message"
+  exit 1
+}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09737fc and 85c4800.

📒 Files selected for processing (1)
  • infra/scripts/certs.sh (1 hunks)
🔇 Additional comments (2)
infra/scripts/certs.sh (2)

9-23: LGTM! Good file handling practices

The file handling is well-implemented with proper error checking and atomic operations.


1-1: Verify script permissions

Ensure the script has executable permissions set.

✅ Verification successful

Script permissions are correctly set

The script already has executable permissions (755/-rwxr-xr-x) which allows execution by owner, group, and others.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the script has executable permissions
ls -l infra/scripts/certs.sh | grep -q '^-rwx' || echo "Warning: Script is not executable"

Length of output: 48


Script:

#!/bin/bash
# Let's check the actual permissions of the script
ls -l infra/scripts/certs.sh

Length of output: 102

infra/scripts/certs.sh Show resolved Hide resolved
infra/scripts/certs.sh Show resolved Hide resolved
@robertaandersen robertaandersen deleted the chore/cert_CNAME_script branch December 13, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants