Esempio n. 1
0
            /// <summary>
            /// Creates an <see cref="IntrinsicInfo"/> for an ImportValue intrinsic.
            /// </summary>
            /// <param name="importValueIntrinsic">The import value intrinsic.</param>
            /// <param name="currentPath">The current path.</param>
            /// <returns>An <see cref="IntrinsicInfo"/></returns>
            private IntrinsicInfo ProcessImportValue(
                ImportValueIntrinsic importValueIntrinsic,
                PropertyPath currentPath)
            {
                // Evaluation will be the name of the export
                var target = importValueIntrinsic.Evaluate(this.template).ToString();
                var export = this.settings.StackExports.FirstOrDefault(e => e.Name == target);

                if (export == null)
                {
                    throw new MissingExportWarning(
                              importValueIntrinsic,
                              this.currentCloudFormationResource,
                              currentPath);
                }

                return(new IntrinsicInfo(currentPath, importValueIntrinsic, null, export.Value));
            }
Esempio n. 2
0
        /// <summary>
        /// Renders the specified import value intrinsic.
        /// </summary>
        /// <param name="importValueIntrinsic">The import value intrinsic.</param>
        /// <param name="template">The template.</param>
        /// <param name="inputs">The list of input variables and data sources.</param>
        /// <returns>A <see cref="DataSourceReference"/> to <c>aws_cloudformation_export</c></returns>
        // ReSharper disable once SuggestBaseTypeForParameter - want this to be explicit.
        private static Reference Render(ImportValueIntrinsic importValueIntrinsic, ITemplate template, IList <InputVariable> inputs)
        {
            var exportName        = importValueIntrinsic.Evaluate(template).ToString();
            var dataSourceAddress = $"aws_cloudformation_export.{exportName}";

            // Add an entry to parameters so it gets emitted
            if (!inputs.Any(i => i.IsDataSource && i.Address == dataSourceAddress))
            {
                inputs.Add(
                    new DataSourceInput(
                        "aws_cloudformation_export",
                        exportName,
                        new Dictionary <string, string> {
                    { "name ", exportName }
                }));
            }

            return(new DataSourceReference("aws_cloudformation_export", exportName, "value", false));
        }