|
9 | 9 |
|
10 | 10 | "github.com/aws/aws-sdk-go/aws"
|
11 | 11 | "github.com/aws/aws-sdk-go/aws/session"
|
| 12 | + "github.com/aws/aws-sdk-go/service/dynamodb" |
12 | 13 | "github.com/aws/aws-sdk-go/service/organizations"
|
13 | 14 | "github.com/aws/aws-sdk-go/service/s3"
|
14 | 15 | "github.com/santiago-labs/telophasecli/cmd"
|
@@ -916,6 +917,86 @@ Organization:
|
916 | 917 | },
|
917 | 918 | Targets: []string{"stacks"},
|
918 | 919 | },
|
| 920 | + { |
| 921 | + Name: "Cloudformation example", |
| 922 | + OrgYaml: ` |
| 923 | +Organization: |
| 924 | + Name: root |
| 925 | + Accounts: |
| 926 | + - AccountName: master |
| 927 | + |
| 928 | + Stacks: |
| 929 | + - Type: Cloudformation |
| 930 | + Path: cloudformation/table.yml |
| 931 | + Region: us-west-2 |
| 932 | + CloudformationParameters: |
| 933 | + - "HashKeyElementName=Painter" |
| 934 | + - "TableName=test" |
| 935 | + - AccountName: test |
| 936 | + |
| 937 | +`, |
| 938 | + FetchExpected: &resource.OrganizationUnit{ |
| 939 | + OUName: "root", |
| 940 | + Accounts: []*resource.Account{ |
| 941 | + { |
| 942 | + AccountName: "master", |
| 943 | + |
| 944 | + ManagementAccount: true, |
| 945 | + }, |
| 946 | + }, |
| 947 | + }, |
| 948 | + ParseExpected: &resource.OrganizationUnit{ |
| 949 | + OUName: "root", |
| 950 | + ChildOUs: []*resource.OrganizationUnit{}, |
| 951 | + Accounts: []*resource.Account{ |
| 952 | + { |
| 953 | + AccountName: "master", |
| 954 | + |
| 955 | + ManagementAccount: true, |
| 956 | + BaselineStacks: []resource.Stack{ |
| 957 | + { |
| 958 | + Type: "Cloudformation", |
| 959 | + Path: "cloudformation/table.yml", |
| 960 | + Region: "us-west-2", |
| 961 | + CloudformationParameters: []string{ |
| 962 | + "HashKeyElementName=Painter", |
| 963 | + "TableName=test", |
| 964 | + }, |
| 965 | + }, |
| 966 | + }, |
| 967 | + }, |
| 968 | + { |
| 969 | + AccountName: "test", |
| 970 | + |
| 971 | + }, |
| 972 | + }, |
| 973 | + }, |
| 974 | + ExpectedResources: func(t *testing.T) { |
| 975 | + sess, err := session.NewSession(&aws.Config{ |
| 976 | + Region: aws.String("us-west-2"), |
| 977 | + Endpoint: aws.String("http://localhost:4566"), |
| 978 | + S3ForcePathStyle: aws.Bool(true), |
| 979 | + }) |
| 980 | + if err != nil { |
| 981 | + t.Fatalf("Failed to create session: %v", err) |
| 982 | + } |
| 983 | + |
| 984 | + svc := dynamodb.New(sess) |
| 985 | + |
| 986 | + result, err := svc.ListTables(&dynamodb.ListTablesInput{}) |
| 987 | + if err != nil { |
| 988 | + t.Fatalf("Failed to list buckets: %v", err) |
| 989 | + } |
| 990 | + |
| 991 | + if len(result.TableNames) == 0 { |
| 992 | + t.Fatal("No tables created") |
| 993 | + } |
| 994 | + |
| 995 | + fmt.Println("table name", *result.TableNames[0]) |
| 996 | + assert.Equal(t, *result.TableNames[0], "test") |
| 997 | + }, |
| 998 | + Targets: []string{"stacks"}, |
| 999 | + }, |
919 | 1000 | }
|
920 | 1001 |
|
921 | 1002 | func TestEndToEnd(t *testing.T) {
|
|
0 commit comments