- 
                Notifications
    You must be signed in to change notification settings 
- Fork 46
chore: new govcloud release script #567
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
          
     Merged
      
      
            apiarian-datadog
  merged 6 commits into
  main
from
aleksandr.pasechnik/update-govcloud-deploy-script
  
      
      
   
  Mar 4, 2025 
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            6 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      544a96a
              
                chore: there is no staging environment name
              
              
                apiarian-datadog 2528f4a
              
                chore: turn environments into a dictionary
              
              
                apiarian-datadog 54c3e43
              
                chore: move sign-layer out of the loop
              
              
                apiarian-datadog 0e22507
              
                chore: layer bundle jobs
              
              
                apiarian-datadog 94f4aa4
              
                chore: remove the govcloud bits from the publish_prod.sh script
              
              
                apiarian-datadog 97cc029
              
                chore: new gov publish script
              
              
                apiarian-datadog File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| environments: | ||
| - name: sandbox | ||
| sandbox: | ||
| external_id: sandbox-publish-externalid | ||
| role_to_assume: sandbox-layer-deployer | ||
| account: 425362996713 | ||
| - name: prod | ||
| prod: | ||
| external_id: prod-publish-externalid | ||
| role_to_assume: dd-serverless-layer-deployer-role | ||
| account: 464622532012 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| #! /usr/bin/env bash | ||
|  | ||
| # Unless explicitly stated otherwise all files in this repository are licensed | ||
| # under the Apache License Version 2.0. | ||
| # This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| # Copyright 2025 Datadog, Inc. | ||
| # | ||
| # USAGE: download the layer bundle from the build pipeline in gitlab. Use the | ||
| # Download button on the `layer bundle` job. This will be a zip file containing | ||
| # all of the required layers. Run this script as follows: | ||
| # | ||
| # ENVIRONMENT=[us1-staging-fed or us1-fed] [LAYER_NAME_SUFFIX=optional-layer-suffix] [REGIONS=us-gov-west-1] ./scripts/publish_govcloud.sh <layer-bundle.zip> | ||
| # | ||
| # protip: you can drag the zip file from finder into your terminal to insert | ||
| # its path. | ||
|  | ||
| set -e | ||
|  | ||
| LAYER_PACKAGE=$1 | ||
|  | ||
| if [ -z "$LAYER_PACKAGE" ]; then | ||
| printf "[ERROR]: layer package not provided\n" | ||
| exit 1 | ||
| fi | ||
|  | ||
| PACKAGE_NAME=$(basename "$LAYER_PACKAGE" .zip) | ||
|  | ||
| if [ -z "$ENVIRONMENT" ]; then | ||
| printf "[ERROR]: ENVIRONMENT not specified\n" | ||
| exit 1 | ||
| fi | ||
|  | ||
| if [ "$ENVIRONMENT" = "us1-staging-fed" ]; then | ||
| AWS_VAULT_ROLE=sso-govcloud-us1-staging-fed-power-user | ||
|  | ||
| export STAGE=gov-staging | ||
|  | ||
| if [[ ! "$PACKAGE_NAME" =~ ^datadog_lambda_py-(signed-)?bundle-[0-9]+$ ]]; then | ||
| echo "[ERROR]: Unexpected package name: $PACKAGE_NAME" | ||
| exit 1 | ||
| fi | ||
|  | ||
| elif [ $ENVIRONMENT = "us1-fed" ]; then | ||
| AWS_VAULT_ROLE=sso-govcloud-us1-fed-engineering | ||
|  | ||
| export STAGE=gov-prod | ||
|  | ||
| if [[ ! "$PACKAGE_NAME" =~ ^datadog_lambda_py-signed-bundle-[0-9]+$ ]]; then | ||
| echo "[ERROR]: Unexpected package name: $PACKAGE_NAME" | ||
| exit 1 | ||
| fi | ||
|  | ||
| else | ||
| printf "[ERROR]: ENVIRONMENT not supported, must be us1-staging-fed or us1-fed.\n" | ||
| exit 1 | ||
| fi | ||
|  | ||
| TEMP_DIR=$(mktemp -d) | ||
| unzip $LAYER_PACKAGE -d $TEMP_DIR | ||
| cp -v $TEMP_DIR/$PACKAGE_NAME/*.zip .layers/ | ||
|  | ||
|  | ||
| AWS_VAULT_PREFIX="aws-vault exec $AWS_VAULT_ROLE --" | ||
|  | ||
| echo "Checking that you have access to the GovCloud AWS account" | ||
| $AWS_VAULT_PREFIX aws sts get-caller-identity | ||
|  | ||
|  | ||
| AVAILABLE_REGIONS=$($AWS_VAULT_PREFIX aws ec2 describe-regions | jq -r '.[] | .[] | .RegionName') | ||
|  | ||
| # Determine the target regions | ||
| if [ -z "$REGIONS" ]; then | ||
| echo "Region not specified, running for all available regions." | ||
| REGIONS=$AVAILABLE_REGIONS | ||
| else | ||
| echo "Region specified: $REGIONS" | ||
| if [[ ! "$AVAILABLE_REGIONS" == *"$REGIONS"* ]]; then | ||
| echo "Could not find $REGIONS in available regions: $AVAILABLE_REGIONS" | ||
| echo "" | ||
| echo "EXITING SCRIPT." | ||
| exit 1 | ||
| fi | ||
| fi | ||
|  | ||
| for region in $REGIONS | ||
| do | ||
| echo "Starting publishing layers for region $region..." | ||
|  | ||
| export REGION=$region | ||
|  | ||
| for python_version in "3.8" "3.9" "3.10" "3.11" "3.12" "3.13"; do | ||
| for arch in "amd64" "arm64"; do | ||
| export PYTHON_VERSION=$python_version | ||
| export ARCH=$arch | ||
|  | ||
| export SKIP_PIP_INSTALL=true | ||
|  | ||
| echo "Publishing layer for $PYTHON_VERSION and $ARCH" | ||
|  | ||
| $AWS_VAULT_PREFIX ./ci/publish_layers.sh | ||
| done | ||
| done | ||
| done | ||
|  | ||
| echo "Done !" | 
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.