Skip to content

Commit 482f297

Browse files
authored
go1.x to provided.al2 migration (#230)
* provided.al2 migration
1 parent 248be6d commit 482f297

File tree

9 files changed

+38
-22
lines changed

9 files changed

+38
-22
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ out.java
117117
out/
118118
tmp/
119119

120+
# generated files
121+
examples/github-repo/makebuild
122+
examples/github-repo/cmd/resource/config.go
123+
120124
# Binaries for programs and plugins
121125
*.exe
122126
*.exe~

.pre-commit-config.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ repos:
6464
description: Run pytest in the local virtualenv
6565
entry: >
6666
pytest
67-
--cov-report=term
68-
--cov-report=html
69-
--cov="rpdk.go"
7067
--durations=5
7168
"tests/"
7269
language: system

examples/github-repo/.rpdk-config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"typeName": "Example::GitHub::Repo",
33
"language": "go",
4-
"runtime": "go1.x",
5-
"entrypoint": "handler",
6-
"testEntrypoint": "handler",
4+
"runtime": "provided.al2",
5+
"entrypoint": "bootstrap",
6+
"testEntrypoint": "bootstrap",
77
"settings": {
88
"import_path": "github.com/aws-cloudformation/cloudformation-cli-go-plugin/examples/github-repo",
99
"protocolVersion": "2.0.0",

examples/github-repo/docs/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ _Required_: Yes
4343

4444
_Type_: String
4545

46-
_Minimum_: <code>1</code>
46+
_Minimum Length_: <code>1</code>
4747

48-
_Maximum_: <code>50</code>
48+
_Maximum Length_: <code>50</code>
4949

5050
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
5151

@@ -67,9 +67,9 @@ _Required_: No
6767

6868
_Type_: String
6969

70-
_Minimum_: <code>20</code>
70+
_Minimum Length_: <code>20</code>
7171

72-
_Maximum_: <code>250</code>
72+
_Maximum Length_: <code>250</code>
7373

7474
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
7575

@@ -81,9 +81,9 @@ _Required_: No
8181

8282
_Type_: String
8383

84-
_Minimum_: <code>20</code>
84+
_Minimum Length_: <code>20</code>
8585

86-
_Maximum_: <code>250</code>
86+
_Maximum Length_: <code>250</code>
8787

8888
_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)
8989

examples/github-repo/resource-role.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ Resources:
1515
Principal:
1616
Service: resources.cloudformation.amazonaws.com
1717
Action: sts:AssumeRole
18+
Condition:
19+
StringEquals:
20+
aws:SourceAccount:
21+
Ref: AWS::AccountId
22+
StringLike:
23+
aws:SourceArn:
24+
Fn::Sub: arn:${AWS::Partition}:cloudformation:${AWS::Region}:${AWS::AccountId}:type/resource/Example-GitHub-Repo/*
1825
Path: "/"
1926
Policies:
2027
- PolicyName: ResourceTypePolicy

examples/github-repo/template.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ Globals:
99
Resources:
1010
TypeFunction:
1111
Type: AWS::Serverless::Function
12+
Metadata:
13+
BuildMethod: go1.x
1214
Properties:
13-
Handler: handler
14-
Runtime: go1.x
15+
Handler: bootstrap
16+
Runtime: provided.al2
17+
Architectures:
18+
- x86_64
1519
CodeUri: bin/
1620
# Uncomment to test with AWS resources
1721
# Environment:
@@ -20,7 +24,11 @@ Resources:
2024

2125
TestEntrypoint:
2226
Type: AWS::Serverless::Function
27+
Metadata:
28+
BuildMethod: go1.x
2329
Properties:
24-
Handler: handler
25-
Runtime: go1.x
30+
Handler: bootstrap
31+
Runtime: provided.al2
32+
Architectures:
33+
- x86_64
2634
CodeUri: bin/

python/rpdk/go/codegen.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class GoExecutableNotFoundError(SysExitRecommendedError):
3232
class GoLanguagePlugin(LanguagePlugin):
3333
MODULE_NAME = __name__
3434
NAME = "go"
35-
RUNTIME = "go1.x"
36-
ENTRY_POINT = "handler"
37-
TEST_ENTRY_POINT = "handler"
35+
RUNTIME = "provided.al2"
36+
ENTRY_POINT = "bootstrap"
37+
TEST_ENTRY_POINT = "bootstrap"
3838
CODE_URI = "bin/"
3939

4040
def __init__(self):
@@ -251,7 +251,7 @@ def pre_package(project: Project):
251251

252252
@staticmethod
253253
def _find_exe(project: Project):
254-
exe_glob = list((project.root / "bin").glob("handler"))
254+
exe_glob = list((project.root / "bin").glob("bootstrap"))
255255
if not exe_glob:
256256
LOG.debug("No Go executable match")
257257
raise GoExecutableNotFoundError(

python/rpdk/go/templates/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build:
55

66
test:
77
cfn generate
8-
env GOOS=linux go build -ldflags="-s -w" -o bin/handler cmd/main.go
8+
env GOOS=linux go build -ldflags="-s -w" -tags="lambda.norpc,$(TAGS)" -o bin/bootstrap cmd/main.go
99

1010
clean:
1111
rm -rf bin

python/rpdk/go/templates/makebuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
.PHONY: build
55
build:
66
cfn generate
7-
env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -tags="$(TAGS)" -o bin/handler cmd/main.go
7+
env GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -tags="lambda.norpc,$(TAGS)" -o bin/bootstrap cmd/main.go

0 commit comments

Comments
 (0)