deployment: change some wrong names at cloudformation lambda. Remove not needed return

pull/711/head
cruizba 2022-03-24 21:13:50 +01:00
parent ff2dc6d86b
commit 80b097e379
2 changed files with 12 additions and 13 deletions

View File

@ -284,7 +284,7 @@ Resources:
owner: "root" owner: "root"
group: "root" group: "root"
Properties: Properties:
ImageId: !GetAtt LambdaCopyAmiInvoke.ImageId ImageId: !GetAtt CloudformationLambdaInvoke.ImageId
InstanceType: !Ref InstanceType InstanceType: !Ref InstanceType
SecurityGroups: SecurityGroups:
- !Ref WebServerSecurityGroup - !Ref WebServerSecurityGroup
@ -422,7 +422,7 @@ Resources:
########## ##########
# Lambda to Copy original AMI to the deployment region # Lambda to Copy original AMI to the deployment region
########## ##########
LambdaCopyAmiRole: CloudformationLambdaRole:
Type: 'AWS::IAM::Role' Type: 'AWS::IAM::Role'
DeletionPolicy: Delete DeletionPolicy: Delete
Properties: Properties:
@ -437,7 +437,7 @@ Resources:
- 'sts:AssumeRole' - 'sts:AssumeRole'
Path: / Path: /
Policies: Policies:
- PolicyName: !Join ['', [ !Ref AWS::StackName, '-lambda-policy-ami-copy'] ] - PolicyName: !Join ['', [ !Ref AWS::StackName, '-cf-lambda-policy'] ]
PolicyDocument: PolicyDocument:
Version: 2012-10-17 Version: 2012-10-17
Statement: Statement:
@ -446,13 +446,13 @@ Resources:
- 'ec2:DescribeImages' - 'ec2:DescribeImages'
- 'ec2:CopyImage' - 'ec2:CopyImage'
Resource: '*' Resource: '*'
RoleName: !Join ['', [ !Ref AWS::StackName, '-lambda-role-ami-copy'] ] RoleName: !Join ['', [ !Ref AWS::StackName, '-cf-lambda-role'] ]
LambdaCopyAmi: CloudformationLambda:
Type: AWS::Lambda::Function Type: AWS::Lambda::Function
DeletionPolicy: Delete DeletionPolicy: Delete
Properties: Properties:
FunctionName: !Join ['', [ !Ref AWS::StackName, '-lambda-ami-copy'] ] FunctionName: !Join ['', [ !Ref AWS::StackName, '-cf-lambda'] ]
Code: Code:
ZipFile: | ZipFile: |
import boto3 import boto3
@ -518,16 +518,16 @@ Resources:
Handler: index.handler Handler: index.handler
Role: Role:
!GetAtt LambdaCopyAmiRole.Arn !GetAtt CloudformationLambdaRole.Arn
Runtime: python3.7 Runtime: python3.7
Timeout: 900 Timeout: 900
LambdaCopyAmiInvoke: CloudformationLambdaInvoke:
Type: AWS::CloudFormation::CustomResource Type: AWS::CloudFormation::CustomResource
DeletionPolicy: Delete DeletionPolicy: Delete
Version: "1.0" Version: "1.0"
Properties: Properties:
ServiceToken: !GetAtt LambdaCopyAmi.Arn ServiceToken: !GetAtt CloudformationLambda.Arn
AmiSourceRegion: 'eu-west-1' AmiSourceRegion: 'eu-west-1'
AmiSourceId: !FindInMap [OVAMIMAP, 'eu-west-1', AMI] AmiSourceId: !FindInMap [OVAMIMAP, 'eu-west-1', AMI]
DeploymentRegion: !Ref AWS::Region DeploymentRegion: !Ref AWS::Region

View File

@ -835,7 +835,7 @@ Resources:
- 'sts:AssumeRole' - 'sts:AssumeRole'
Path: / Path: /
Policies: Policies:
- PolicyName: !Join ['', [ !Ref AWS::StackName, '-lambda-policy-ami-copy'] ] - PolicyName: !Join ['', [ !Ref AWS::StackName, '-cf-lambda-policy'] ]
PolicyDocument: PolicyDocument:
Version: 2012-10-17 Version: 2012-10-17
Statement: Statement:
@ -861,13 +861,13 @@ Resources:
'aws:ResourceTag/ov-cluster-member': 'kms' 'aws:ResourceTag/ov-cluster-member': 'kms'
'aws:ResourceTag/ov-stack-name': !Ref AWS::StackName 'aws:ResourceTag/ov-stack-name': !Ref AWS::StackName
'aws:ResourceTag/ov-stack-region': !Ref AWS::Region 'aws:ResourceTag/ov-stack-region': !Ref AWS::Region
RoleName: !Join ['', [ !Ref AWS::StackName, '-lambda-role-ami-copy'] ] RoleName: !Join ['', [ !Ref AWS::StackName, '-cf-lambda-role'] ]
CloudformationLambda: CloudformationLambda:
Type: AWS::Lambda::Function Type: AWS::Lambda::Function
DeletionPolicy: Delete DeletionPolicy: Delete
Properties: Properties:
FunctionName: !Join ['', [ !Ref AWS::StackName, '-lambda-ami-copy'] ] FunctionName: !Join ['', [ !Ref AWS::StackName, '-cf-lambda'] ]
Code: Code:
ZipFile: | ZipFile: |
import boto3 import boto3
@ -878,7 +878,6 @@ Resources:
try: try:
if (event['RequestType'] == 'Create'): if (event['RequestType'] == 'Create'):
copy_ami(event, context) copy_ami(event, context)
return
elif (event['RequestType'] == 'Delete'): elif (event['RequestType'] == 'Delete'):
removeMediaNodes(event, context) removeMediaNodes(event, context)
else: else: