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

DS-237 Update make file #197

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,31 @@ aws-lambda-get-latest-version: ### Fetches the latest function version for a lam
--output json \
"

aws-lambda-create-alias: ### Creates an alias for a lambda version - Mandatory NAME=[lambda function name], VERSION=[lambda version]
aws-lambda-create-alias: ### Creates aliases for a lambda version - Mandatory NAME=[lambda function name], VERSION=[lambda version]
ALIAS_SUFFIX=""
if [ "$(TF_VAR_drd_mock)" == "True" ]; then
ALIAS_SUFFIX="-mock"
fi
if [ "$(TF_VAR_drd_mock)" == "True" ]; then \
ALIAS_SUFFIX="-mock"; \
fi; \
make -s docker-run-tools ARGS="$$(echo $(AWSCLI) | grep awslocal > /dev/null 2>&1 && echo '--env LOCALSTACK_HOST=$(LOCALSTACK_HOST)' ||:)" CMD=" \
$(AWSCLI) lambda create-alias \
--name $(VERSION)-$(BUILD_COMMIT_HASH)$$ALIAS_SUFFIX \
--function-name $(NAME) \
--function-version $(VERSION) \
"

--function-version $(VERSION) || \
$(AWSCLI) lambda update-alias \
--name $(VERSION)-$(BUILD_COMMIT_HASH)$$ALIAS_SUFFIX \
--function-name $(NAME) \
--function-version $(VERSION); \
echo 'Waiting for alias propagation...'; \
sleep 5; \
$(AWSCLI) lambda create-alias \
--name latest-rd-lambda-version \
--function-name $(NAME) \
--function-version $(VERSION) || \
$(AWSCLI) lambda update-alias \
--name latest-rd-lambda-version \
--function-name $(NAME) \
--function-version $(VERSION); \
"
# --------------------------------------

deployment-summary: # Returns a deployment summary
Expand Down
2 changes: 1 addition & 1 deletion build/jenkins/Jenkinsfile.live.stages
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pipeline {
agent any
parameters {
choice(name: 'ENVIRONMENT', choices: ['build', 'live'], description: 'Environment of the Stage to deploy')
string(name: 'LAMBDA_VERSION', defaultValue: 'latest', description: 'Version or alias of the RD Lambda for stage to point at')
string(name: 'LAMBDA_VERSION', defaultValue: 'latest-rd-lambda-version', description: 'Version or alias of the RD Lambda for stage to point at')
}
options {
buildDiscarder(logRotator(daysToKeepStr: "7", numToKeepStr: "13"))
Expand Down
2 changes: 1 addition & 1 deletion build/jenkins/Jenkinsfile.put.stages
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pipeline {
agent any
parameters {
choice(name: 'ENVIRONMENT', choices: ['build', 'uat1', 'uat2', 'uat3', 'uat4', 'ut'], description: 'Environment of the Stage to deploy')
string(name: 'LAMBDA_VERSION', defaultValue: 'latest', description: 'Version or alias of the RD Lambda for stage to point at')
string(name: 'LAMBDA_VERSION', defaultValue: 'latest-rd-lambda-version', description: 'Version or alias of the RD Lambda for stage to point at')
}
options {
buildDiscarder(logRotator(daysToKeepStr: "7", numToKeepStr: "13"))
Expand Down
2 changes: 1 addition & 1 deletion build/jenkins/Jenkinsfile.stages
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pipeline {
agent any
parameters {
choice(name: 'ENVIRONMENT', choices: ['build', 'test', 'test1', 'test2', 'test3', 'test4', 'test5', 'istest1', 'istest2', 'istest3', 'fix', 'performance', 'performance2', 'regression'], description: 'Environment of the Stage to deploy')
string(name: 'LAMBDA_VERSION', defaultValue: 'latest', description: 'Version or alias of the RD Lambda for stage to point at')
string(name: 'LAMBDA_VERSION', defaultValue: 'latest-rd-lambda-version', description: 'Version or alias of the RD Lambda for stage to point at')
}
options {
buildDiscarder(logRotator(daysToKeepStr: '7', numToKeepStr: '13'))
Expand Down
1 change: 1 addition & 0 deletions infrastructure/stacks/api-stage/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ resource "aws_lambda_permission" "road_distance_invoke_lambda_permission" {
function_name = "${var.service_prefix}-rd-lambda:${var.lambda_version}"
principal = "apigateway.amazonaws.com"
source_arn = "${data.terraform_remote_state.api_gateway.outputs.api_execution_arn}/*/*/"
depends_on = [aws_lambda_alias.latest-rd-lambda-version]
}

resource "aws_cloudwatch_log_group" "road_distance_lambda_log_group" {
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/stacks/lambda/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ resource "aws_lambda_function" "road_distance_lambda" {
]
}

resource "aws_lambda_alias" "latest-rd-lambda-version" {
name = "latest-rd-lambda-version"
function_name = "${var.service_prefix}-rd-lambda"
function_version = aws_lambda_function.road_distance_lambda.version
}

resource "aws_lambda_function_event_invoke_config" "road_distance_lambda_invoke_config" {
function_name = aws_lambda_function.road_distance_lambda.function_name
maximum_retry_attempts = 0
Expand Down
8 changes: 4 additions & 4 deletions infrastructure/stacks/secrets/locals.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
locals {
standard_tags = {
"Programme" = var.programme
"Service" = "core-dos"
"Programme" = var.programme
"Service" = "core-dos"
"SharedService" = "dos"
"Product" = "core-dos"
"Environment" = var.profile
"Product" = "core-dos"
"Environment" = var.profile
}
}
Loading