Beispiel #1
0
            /// <summary>
            /// Begin processing an intrinsic.
            /// </summary>
            /// <param name="intrinsic">The intrinsic.</param>
            /// <param name="currentPath">The current path.</param>
            public void EnterIntrinsic(IIntrinsic intrinsic, PropertyPath currentPath)
            {
                if (this.lastWarning != null)
                {
                    // Something that can't be resolved has been found,
                    // so don't process any more here.
                    return;
                }

                var clonedPath = currentPath.Clone();

                try
                {
                    if (this.parentIntrinsicPath == null)
                    {
                        // This is a "top level" intrinsic associated directly with a resource attribute.
                        if (this.currentCloudFormationResource.Type == "AWS::Lambda::Permission" &&
                            currentPath.Path == "FunctionName" && intrinsic is RefIntrinsic)
                        {
                            // !! NASTY KLUDGE ALERT !!
                            // AWS treats this property as a !Ref which is lambda function's name, but terraform actually wants the ARN here.
                            // If I find more cases like this, then I'll put something into resource traits
                            intrinsic = new GetAttIntrinsic(
                                intrinsic.GetReferencedObjects(this.template).First(),
                                "Arn");
                        }

                        this.intrinsicInfos.Push(this.currentIntrinsicInfo);
                        this.parentIntrinsicPath  = clonedPath;
                        this.currentIntrinsicInfo = this.GetIntrinsicInfo(intrinsic, currentPath);
                    }
                    else
                    {
                        // We have descended the graph to member intrinsic
                        this.intrinsicInfos.Push(this.currentIntrinsicInfo);
                        var intrinsicInfo = this.GetIntrinsicInfo(intrinsic, currentPath);
                        this.currentIntrinsicInfo.NestedIntrinsics.Add(intrinsicInfo);

                        this.currentIntrinsicInfo = intrinsicInfo;
                    }
                }
                catch (DependencyResolutionWarning w)
                {
                    this.lastWarning = w;
                }
            }